Facebook post by University of Helsinki

Experiencing earworms, or imagining music without trying, is an ordinary memory phenomenon connected to environmental stimuli. It is a unique mnemonic phenomenon different from other types of involuntary memory.
Unwanted music in the head is an uplifting part of everyday life | University of Helsinki helsinki.fi

Lassi A. Liikkanen investigated imagined music in his doctoral dissertation, a phenomenon known as an earworm.