earworm
A tune that keeps replaying in one's head or that one keeps thinking about, especially if unwanted.
The chorus [of "Meeting in the Ladies Room" by Klymaxx] spawned an earworm so potent that women still mutter it as they exit for a bathroom break twenty years later.
An earwig; an insect of the order Dermaptera.
archaic
Earwig, [...] The ear-worm or grub, a well-known insect, with large transparent wings, which eats fruit and flower-leaves, and has been erroneously supposed to creep into the human brain through the ear; [...]
Where it comes from
From ear + worm; senses 1 and 3 (“tune that keeps replaying in one’s head”; “earwig”) are a calque of German Ohrwurm (“tune that pops up in one’s memory all the time; earwig”) (from the idea of a creature burrowing into the ear, an erroneous belief where earwigs are concerned), while sense 2 (“moth larva”) refers to the fact that these pests infest, among other things, ears of maize or sweet corn.
Adapted from the Wiktionary entry earworm (CC BY-SA 4.0).