Some people literally call it a 'stuck thought' as for example in this extract where it is used in the context of certain anxiety disorders:

>**Stuck thoughts**; thoughts, mental images, concepts, songs, or melodies that stick in your mind and replay over and over again.



Source: http://www.anxietycentre.com/anxiety-symptoms/thoughts-that-seem-stuck.shtml