Someone, I forget who, coined a word for that: earworm! Probably derived from computer worm, which is hard to eradicate from one's hard drive!