I get songs stuck in my head a lot. Sometimes it's because I have just heard them on the radio and then it will stay in my head the rest of the day or until a new song gets stuck in my head.
Sometimes, a song will just randomly pop in my head and then if I turn the radio on, that song will be on. This happens with movies too. I once heard that our brains can pick up on radio signals and that why we subconsiously get things in our head. Not sure about that though. Perhaps it's a coincidence that happens frequently.
I've heard different myths on how to get songs out of your head. One was to hear the song in its entirety so that your brain will now the song is done. Another was to start doing math. Sometimes it works, sometimes not.
Here are some other entertaining suggestions on how to rid your mind of the earworms: