I imagine you believe he didn't know who she was until she had borne a son?
No. Try again.
This is what is called a Biblical euphemism. In the quaint old days they didn't speak of sex or pregnancy directly. Saying that someone "knew" someone is a euphemism meaning that they had had sexual intercourse.
The point to this little story is that Mary was a virgin when Jesus was born. That's all. The point is not what happened after and this does not speak at all about what happens after. It speaks to the fact that they did not have sex at all before Jesus was born. That makes it a miracle we call "the Virgin Birth"
SD