The energy cost is zero. In desalination, you take the ions that were in one body of water and move them to a different body of water, but the energy is the same no matter where the ions are. Desalination is about paying the entropy cost, not the energy cost.

We imagine the desalination process part-way complete. On the left we have the ocean with a constant concentration of ions. On the right we have water we're trying to desalinate, which currently has concentration of ions. How much does the entropy change if we move an ion from the right to the left?

You may know the formula for entropy, where is the number of possible states of the system. We need a way to estimate .

Imagine each ion living in its own little house, with all the houses jammed up next to each other to take up all the space in the water. When the concentration of ions is low the houses are big and when the concentration is high the houses are small. The volume of each house is .

The ion can wander around anywhere inside its house. That means that if you make the house twice as big, there are twice as many possible states for the molecule. States are proportional to volume. In an equation, where is just a constant of proportionality that won't matter because it cancels out.

The entropy of being on the right is therefore and the entropy of being on the left is . The change in entropy when a molecule moves from right to left is

where is the number of ions in the water we're desalinating.

When the concentrations are equal, we're at equilibrium and this expression comes to zero. When is smaller than the expression is negative, meaning we are decreasing the entropy when we desalinate. To desalinate completely, we need to take down from to zero, so the average entropy decrease per ion is

If we want to desalinate a volume of water , then it has ions, so the total entropy cost is

The total entropy of the universe can't go down, so you need to increase the entropy of something else by at least this much to complete the desalination.

You can pay this entropy cost however you like. For example, you could theoretically set up a device that takes in salt water and 1 TB hard drives full of 0's. It then writes over the hard drives with random bits, increasing their entropy by bytes, or in our units (base ). Sea water has roughly ions per liter, so each hard drive would yield a maximum of about liters. All of Google's servers processed in this way would only make about a cubic centimeter of desalinated water.

More realistically, suppose we do work on the system while holding it at a constant temperature . Then the system gives off an equal amount of heat, and the entropy increase is

(The second equality says that all the work we did gets turned into heat.) Then equating our two entropy expressions, the minimum work is

at room temperature, this is about 0.8 kilowatt hours per cubic meter, or 0.7 kCal/liter. If you rode an exercise bike hooked up to an ideal desalination machine, it could make you a liter of water in about a minute of relaxed riding.

notes:

This answer is written in units where Boltzmann's constant is one. Throughout, I've used the "ideal gas" approximation for solutes - i.e. the solutes don't interact with each other. All of the expressions and statements are approximations; the energy change in moving ions is not precisely zero, just much smaller than the free energy change, etc.