Scientists think of these annoying sound segments as "ear worms." They don't yet know much about why they happen, but research is making headway on what's going on.
The songs that get stuck in people's heads tend to be melodically and rhythmically simple, says Daniel Levitin, a psychologist who studies the neuroscience of music at McGill University in Montreal, Quebec. It's usually just a segment of the song, not the entire thing from beginning to end. A common method of getting rid of an ear worm is to listen to a different song – except, of course, that song might plant itself in your thoughts for awhile…
Music is strongly associated with the brain's reward system. It's the part of the brain that tells us if things are valuable, or important or relevant to survival, said Robert Zatorre, professor of neurology and neurosurgery at Montreal Neurological Institute.