You: "Hey Bill, I've been thinking. It's actually not appropriate for you to walk into my home without knocking. I'd like if you started doing that. It's important to me."
Him: "Why? I always have."
You: "Yes, and I didn't set a boundary. I am now. This is my home, and I expect you to knock before you enter. Thanks, I know you'll be respectful!"
Simple as that. You don't OWE him an explanation, OR entry into your house, particularly not your bedroom. Doesn't matter if you're dating or not!
--Oh wait, I just re-read your question, so let me re-phrase this (occurred to me that he IS knocking, and then just floats into your room).
You: "Hey Bill, if you'd like to say hi to Charlie, you're more than welcome to pet him in the living room. I'd like my bedroom to be left alone."
Him: "Why, ha ha, you dating someone?"
You: "I never set a boundary about my room and now I'd like to. It's my private space. Thanks for understanding!"