It could have been the dream, or something he overheard, or something he saw on TV. Maybe something along the lines of "What is the last thing you said to someone before they died?" or "My friend died in a car crash - I wish I had told her I loved her the last time we spoke."
Ask him more about his dream. Not so much "why do you need to say this?" but more, "tell me everything you remember about your dream. Who was there? Did anyone speak to you? What did they say?" Then give him time to answer! Very important to draw him out. If you have a school counselor, a clergy member, or even a physician (if the pediatrician will take the time), it might make sense to have a 3rd party professional ask the questions.
OCD is a possibility but usually it manifests in more than one way - counting steps, turning a light on and off, clearing the throat, and so on.
It could be a symptom of an anxiety disorder, or it could be a phase. Take some notes with dates/times/situation so you can report it effectively to a counselor.
It could also be nothing. Time and vigilance will tell.