Sometimes we think bad people should get what they deserve, but we shouldn’t liken that punishment to eating day-old pastries.
Yes, lots of people use the phrase “getting his just deserts,” but they are thinking of desserts—sweet treats.
The word desert pronounced with the accent on the second syllable (de-ZERT), brings to mind the verb that means to leave, abandon, or withdraw. But as a noun, that word means “that which one deserves.” Desert, in that sense, is now archaic and rarely used outside this phrase.
In a convoluted way, writing “he got his just desserts” (as in sweets) makes some sense. I picture doling out some awful-tasting moldy cake to a person I feel deserves such a dessert.
But we writers want to be accurate in our handling of language, and so “deserts” is the correct spelling.
Keep in mind that just deserts can mean either reward or punishment (you are getting what you deserve, and maybe you deserve something nice)—whereas comeuppance always implies a negative outcome rightly deserved.
Comeuppance has its origin with “coming up before a judge” for punishment.
I’d be happy for some positive “just deserts”—make mine chocolate cake. Just the desert (or should I say dessert?) I deserve.