its very annoying when this happens ..&.there is actually a term for it, it is called an:
"Earworm"...a portion of a song or other music that repeats compulsively within one's mind, known colloquially as "music being stuck in ones head." People with obsessive-compulsive disorder (OCD) are more likely to report being troubled by ear worms - in some cases, medications for OCD can minimize the effects.Earworms should not be confused with endomusia, a serious affliction, through which a sufferer actually hears music that is not playing externally.