The following is lifted in its entirety from Issue 668 (May 1, 2010) of World Wide Words, an internet magazine.
Q. In last week's issue, in your item on "comeuppance", you wrote "Why should it mean the punishment or fate that someone deserves, a just retribution or just deserts?" Surely that should be "just desserts"? [Megan Zurawicz; related questions came from others.]
A. I didn't make a mistake, but the confusion between the two forms is now so widespread that it's hard to be sure which one is right. The evidence of the Oxford corpus of recent English is that "just desserts" is now more common than "just deserts" (60% against 40%), suggesting it may one day become the standard form. Even my Sunday newspaper, the Observer, had it in a headline on 11 April: "Perhaps the parties will get their just desserts". It wasn't suggesting they might be served with apple pie or Black Forest gateau. The muddle isn't helped by the bakery chains and authors of cookery books who think "just desserts" is a deliciously punning title.
The problem is that there are three nouns involved (and a verb as well, though that's less of an issue), two of them spelled with just one "s" in the middle and the third with two. It's fatally easy to get them mixed up.
We have no problem with "desert" when we mean the dry, barren area or with "dessert" when we refer to the sweet course of a meal. The former is from Latin "desertus", abandoned, deserted or left waste; in turn it's from the verb "deserere", to abandon, which is the source also of the verb. The latter is from French "desservir", to remove what has been served or to clear the table - the dessert course was usually laid out in another room to give the servant free rein to clear the table after the main course. It's the third word - the "desert" in "just deserts" - that causes the trouble, as it's spelled like the barren desert but said like the sweet course. This "desert" is from another Old French verb that means "deserve".
The confusion between "just deserts" and "just desserts" is mainly one of pronunciation. We don't confuse the barren desert with the other two words because it's stressed on the first syllable, while the others are stressed on the second.
It's because the "deserts" in "just deserts" is said the same way as the foodstuff "desserts" that leaves us puzzled how to spell the former. If you need a memory aid, remember the sentence "Deserts are what one deserves". "Deserve" and "desert" both have one "s" and are both stressed on the second syllable. So it's "just deserts".