Did He always know it or was there a point in his young life when Mary, Joseph, or God told Him of his supernatural origin?
He knew before He was born
John also knew it before he was born.
Before I answer, there is important background information that needs to be clear:
Jesus is a Divine Person. Although He has a complete, indeed perfect, human nature, if you ask the question “Who is Jesus?” the answer would be, “God the Son, the Second Person of the Trinity.” We say in theology that Jesus is hypostatically united to the Word or Son. (“Hypostasis” is basically the Greek term for “person” in theology.) It would be incorrect, therefore, to say that Jesus is a human person.
The second thing to consider is that a human nature, which is spiritual in character in addition to being corporeal, always possesses a fully formed intellect (capacity to know things) and will (capacity to love things). Therefore, Jesus possessed these capacities from the moment of his conception (the moment at which he acquired a human nature). He may not have been able to express his intellect and will externally until he reached the age of reason (just as he couldn’t do so when he was asleep), but he had those capacities all the same, ever since his conception. (This is true of all human beings, by the way, not just Jesus.)
Now, a hypostatic union of a human nature with God is the closest union possible with the Creator. In Heaven, we will enjoy a close and intimate union with God, but I think it is obvious that it cannot be nearly as close as the union of Jesus’ human nature with his Divine Person. But in Heaven, as St. Paul and St. John teach us, we will enjoy something called the Beatific Vision: we will see God “face to face.” Vision is, of course, a metaphor, because God (in His Divine Nature) does not have a body that we could physically see, and yet the Scriptures teach us that we will see the very Divine Nature. Therefore, the “vision” is kind of knowledge. (I hope that doesn’t doesn’t sound cold or “intellectualist”: the closest human experience to the Beatific Vision that I can think of is the experience of falling in love; it will be something like that, only infinitely more intense.)
If we, mere creatures, will enjoy a union so close that we will see God face-to-face, it follows that Jesus, who has an even closer union, must also see God face-to-face. After all, he himself is God. And since his intellect was fully formed (as in all men) from the moment of his conception, it follows that he had the Beatific Vision from the moment of his conception.
So the short answer is: Jesus knew he was God, in his human intellect, from the moment of his conception, because he has always possessed the Beatific Vision.
Now that I have given the short answer, things get a little more complicated.
Jesus chose to develop in the normal way: he started out as a zygote, then became an embryo, then an infant, and so on. That means that (like in all of us), the external exercise of his intellect depended on the development of his brain and nervous system.
That means that (also like the rest of us) it took some years before he “reached the age of reason.” He was doubtless a prodigious intellect, but he had to grow into it all the same.
Therefore, there was doubtless a delay in his ability to express his knowledge of his identity. However, as soon as his brain and so forth were fully developed, he would have known about his divinity, and he would not have needed Mary or anyone else to tell him. (From what the Gospel accounts tell us, it seems that even Mary did not quite understand that she was to bear the very Divine Son, until Jesus revealed it to her.)