I've had the "earworm" for a very long time and see it as another aspect of OCD. There's always a melody playing in my head and it's torturous. Oftentimes it's a melody that I enjoy at first, but it becomes an irritation after a whole day of it repeating in my head.
I think low dose naltrexone may have lowered my compulsion to do rituals, but it didn't touch the obsessiveness, earworm, or racing thoughts, so I'm in the same place and can't offer any helpful recommendations. The only thing I'm able to do is listen to a different, preferably catchy song to replace it, but the new melody becomes just as bad quickly.
During my early childhood and the earliest years of being sick, it either wasn't present or it was less severe. I was able to create new music in my mind and "listen" to it, something that would be impossible now with all the mental noise.