Mr M may be right. It’s actually the first thing that popped into my head and is a typical sign of OCD. It’s not necessarily something to worry about unless, also like Mr M said, it interferes with your life.
I’m slightly OCD myself, and I also repeat sentences that I’ve said, in my head, for no particular reason at all. I also find myself counting syllables on my fingers, for every word in a sentence someone just said, immediately after they say it. Then I make it end and begin on every single finger until it’s even. I do it without even realizing it most of the time, but when I do notice and I can’t get myself to stop, it’s highly annoying. I also get gross things stuck in my head which is why I’m very particular about the kind of horror movies I watch. Gory images can pop into my head months or even years, after I watched something and I don’t know how to get them out. (Which is where the counting comes in – it’s a subconscious way your brain distracts itself, thus not allowing any negative images to come into conscious thought.)
Anyway, it’s sounds much more worse than it is. It doesn’t actually distract from my day to day living, thankfully. But yeah, you might wanna check up on it, just in case.