The expression just desserts is a common misspelling of the actual idiom just deserts, which simply means to receive what one deserves. It is one of the more commonly misspelled idiomatic expressions, because it uses an archaic word most people are no longer familiar with. This type of spelling error based on a mishearing of a word, or misunderstanding of its context, is often referred to as an eggcorn.
The expression just deserts is pronounced just desserts, as though using the English word for a sweet after-dinner course, "dessert." Most people, when they see the word "desert," pronounce it differently, as though it is a large arid area of land, complete with sand dunes or palm trees. This is an understandable confusion, as the alternate meaning and the accompanying pronunciation as used in this expression has not been widely used in over a hundred years.
There are two words to consider here. The first is the word "desert," as in, "Lawrence of Arabia spent many years traveling the desert," with the meaning "arid wasteland." This word comes from the same root as the word "desert," as in, "The soldier deserted his company," with the meaning "to abandon." The common root here is the Latin word deserere, meaning to forsake, which made its way through French and Middle English. The secondary meaning of the word, however, with a pronunciation similar to "dessert" comes from an entirely different root. This use, as in, "He got what was coming to him — his just deserts," comes from the Latin deservire through the French. This sense of the term is analogous to the word "deserve," which originates from the same root. The pronunciation makes much more sense when the word "deserve" is considered.
It should be noted that the use of desert in the sense of to deserve has been in English since the mid-13th century. In fact, the use of the expression is noted as early as the end of the 16th century, in the line, “Upon a pillory, that all the world may see: A just desert for such impiety.”
Many people, because of the confusion stemming from the pronunciation, have come up with their own folk etymologies and meanings for this phrase. The most common of these false origins is that just desserts refers to the reward you get at the end of your meal — your dessert — and by extension can be used metaphorically for any sort of reward at the end of a job well done. While this is an admirable attempt at explaining the meaning, the truth is much simpler: it's about getting exactly what one deserves.