|MadSci Network: Neuroscience|
I'm sorry, but I don't know how one gets rid of those annoying song pieces out of one's mind (try listening to another song for a long time). I can tell you, however, what causes them. It's similar to one of those muscle spasms or twitches you get once in a while. You know how annoying they are and how little you can do to stop them. Unrelenting tunes in the head happen for similar reasons. Just as your muscles are controlled by nerves, everything within the mind also corresponds to neurological activity, and this includes mental simulations of music. Corresponding to your mental tune is a certain pattern of neurological activity, and when it repeats uncontrollably, this is likely due to the grouping of neurons undergoing an uncontrolled spasm (due to some foreign factor like a chemical release). So unless you can think of a creative way to intervene into your brain, I don't know how to solve your problem other than suggesting to wait for it to die out.
Try the links in the MadSci Library for more information on Neuroscience.