This is the worst compliment that a teacher can pay attention to. Favorite isn't the goal — greatness is. There can only be one favorite teacher in a child's heart, but there can be dozens of great teachers.
If you're in a position of school culture-building (and all of us are), then you need to give this idea repeated mention: We want schools filled with great teachers, not schools of competitors vying for Favorite, that most fickle of “honors.”
Don't get me wrong: it can be very sweet of a kid to say this kind of thing. (It's not always sweet, though. Sometimes, they've learned that it's a great method for manipulating a teacher.)
So, how do you respond when a kid says, “You're my favorite teacher”? You say, with warm eyes, “Thanks. There are a lot of great teachers in this school.” And then you move on.
The message you've sent, to yourself and to the self-exalting part of your heart, is simple: It's nice that you think that, but I don't teach for those kinds of prizes. I've seen the work beneath the work, and I've given it up. Let's carry on.
I hope this helps.