Studying earworms (or ‘brainworms’ as Oliver Sacks names them) is a topic that would make an ideal PhD thesis: it is a striking, yet unexplained phenomenon, and a research question that is around for quite a while, and (embarrassingly for music cognition) without a sufficient answer. One of the reasons might be - comparable to studying déjà vu’s - that to think of an experiment that can capture the phenomenon when it occurs, is quite a challenge. And, as far as I am aware, no explanation has appeared, as yet, in the scientific journals.
Nevertheless, there is something to say about the structural aspects of the melodies that tend to function as earworms. Most sticky songs are relative simple in terms of their harmonic structure, but have a striking moment - the hook of the song. It is the point in the music where something catchy happens. It is precisely the moment where you would start singing a song from memory (see more at ). That said: this is just an after-the-fact interpretation, not a explanation.
P.S. Interested in earworms? Follow the discussion at Facebook.
 Dutch tv item (with subtitles) on the earworm.