When did Mary and Joseph learn that they were never supposed to have marital relations, according to Roman Catholic doctrine? Roman Catholic doctrine teaches that Mary remained a virgin her entire life, even after marrying Joseph.  It would seem that Joseph and Mary, at their betrothal, had likely expected to have, and anticipated having marital relations with each other in marriage.

So, according to Roman Catholic teaching, when and how did Mary and Joseph learn that marital relations would be denied them?  Did they just never desire that, or did they specifically have to battle the temptation?  It admittedly seems strange to me that this would be withheld from them.

Is it even right to say they were not supposed to have marital relations?  Or should it be said that they never even desired that?
For many the miracle of the Virgin Birth is one thing, but lifelong abstinence from sexuality is impossible to accept. The lives of monastics and ascetics around the world and throughout history attest to the fact that it is possible. Sexual purity is only one of many challenges set for these spiritual warriors, and for many, perhaps most of them, it is not the greatest.  

Mary’s Vow of virginity was before the Annunciation:  

Two important facts are depicted in this verse. First, already at this moment:


  Mary is a virgin betrothed to Joseph, meaning that she is at the first stage of Jewish marriage. She is truly married to Joseph but not yet living with him, for she has not arrived at the second stage of marriage known as the "coming together," when husband and wife typically would begin to live in the same house and consummate the marriage.   
  
  Second, Mary has been told by Gabriel that at some time in the future she will bear a son who will be the royal Son of David, the Messiah-King. Notice the future tense: "You will conceive in your womb and bear a son" (Lk. 1:31, emphasis added). So far, Gabriel gives no indication that the conception will take place right now or in the immediate future. In fact, the timetable is quite open-ended. Without giving any time specification, the angel simply informs Mary that she will conceive this child at some time in the future. 
  
  In this light, Mary’s question seems rather peculiar: ... If Mary is planning on consummating her marriage with Joseph in the near future, the answer to her question should be obvious. While she does not right now have the power to conceive a child (since she doesn’t yet "know" man sexually), if Mary intends to know Joseph after the coming together, then she evidently will be able to have a child at that point. Therefore, if Mary is planning on consummating her marriage with Joseph, her question ... simply does not make sense. (source)


This view has been held by theologians such as St. Augustine, St. Thomas Aquinas, and St. Bonaventure and even Martin Luther.  

Luther wrote on the Virginity of Mary:  


  It is an article of faith that Mary is Mother of the Lord and still a virgin. ... Christ, we believe, came forth from a womb left perfectly intact. (Weimer's The Works of Luther, English translation by Pelikan, Concordia, St. Louis, v. 11, pp. 319-320; v. 6. p. 510.)   


Luther also wrote on February 2, 1546 that Mary was "a virgin before the conception and birth, she remained a virgin also at the birth and after it."   

Calvin also upheld the perpetual virginity of Mary, as did the Swiss reformer, Ulrich Zwingli, who wrote:  


  I firmly believe that Mary, according to the words of the gospel as a pure Virgin brought forth for us the Son of God and in childbirth and after childbirth forever remained a pure, intact Virgin. (Zwingli Opera, Corpus Reformatorum, Berlin, 1905, v. 1, p. 424.)  


Zwingly wrote in January of 1528: "I speak of this in the holy Church of Zurich and in all my writings: I recognize Mary as ever virgin and holy."   

Reason for the belief that Mary was virgin after the birth of Jesus:  

Pope St. Siricius said that God the Father reserved the womb of the Blessed Mother solely for his only-begotten Son. St. Ambrose and St. Thomas Aquinas assigned a spiritual meaning to Ezekiel 44:2:  


  "Then said the LORD unto me; This gate shall be shut, it shall not be opened, and no man shall enter in by it; because the LORD, the God of Israel, hath entered in by it, therefore it shall be shut." (Ezekiel 44:2).  


Mary is the gate, and Jesus was the only one to enter it. This has always been interpreted by the Fathers of the Church to be a typological reference to the Virgin Mary and the Incarnation. When we consider that God took flesh from the Virgin's womb, it is not difficult to imagine that this womb would remain virgin. The place where the saviour of this world was nourished was not to be used by any one else.:-- Base source.  

Further reading here and this source: 


  To say that they had sexual relation after birth of Jesus, Son of God, is to suggest something else that is greatly implausible...: that neither Mary nor her protector, Joseph, would have deemed it inappropriate to have sexual relations after the birth of God in the flesh. ... Mary became the vessel for the Lord of Glory Himself, and bore in the flesh Him whom heaven and earth cannot contain. Would this not have been grounds to consider her life, including her body, as consecrated to God and God alone?  


Then Why Would Mary Marry?:   

A variety of accounts have been offered:


  
  Perhaps since remaining a single woman was not as socially feasible in the ancient world of Judaism as it is today, marriage would have provided economic stability and social protection for Mary. 
  
  Perhaps the marriage was arranged.
  
  Perhaps marriage would free Mary from other men seeking her hand in marriage and thus protect her vow.
  
  Perhaps God led Mary to marriage because in His providence, He wanted to protect her reputation for the future when she would conceive by the Holy Spirit. (source)
  


John Paul II wrote the following in a 1996 papal document:   


  We can wonder why she would accept betrothal, since she had the intention of remaining a virgin forever . . . It may be presumed that at the time of their betrothal there was an understanding between Joseph and Mary about the plan to live as a virgin. Moreover, the Holy Spirit, who had inspired Mary to choose virginity in view of the mystery of the Incarnation and who wanted the latter to come about in a family setting suited to the child’s growth, was quite able to instill in Joseph the ideal of virginity as well.  


If Mary had told Joseph of her vow of virginity (as surely she must have), then we are led to conclude that, since Joseph agreed to marry her, he too must have made a vow of perpetual continence (i.e. to refrain from all sexual relations even within marriage).  


  Surely his wife's miraculous conception and birthgiving (confirmed by the angel in dream-visions) and the sight of God incarnate in the face of the child Christ would have been enough to convince him that his marriage was set apart from the norm. Within Mary's very body had dwelt the second Person of the Trinity. If touching the ark of the covenant had cost Uzzah his life, and if even the scrolls containing the Law, the Psalms, and the Prophets were venerated, certainly Joseph, man of God that he was, would neither have dared nor desired to approach Mary, the chosen of Israel, the throne of God, to request his "conjugal rights"!  (source)