Ignorance of the shar’i ruling is a valid excuse before Allaah, may He be glorified and exalted. Allaah has shown mercy to this ummah and lightened its burden, as He has excused them from sin in cases of ignorance, forgetfulness and compulsion.
It was narrated that Ibn ‘Abbaas (may Allaah be pleased with him) said: When this verse was revealed – “and whether you disclose what is in your own selves or conceal it, Allaah will call you to account for it” [al-Baqarah 2:284] – there entered their hearts something that had never entered them before. The Prophet (peace and blessings of Allaah be upon him) said: “Say: We hear and we obey and we submit.” Then Allaah put faith in their hearts and Allaah revealed the words: “Allaah burdens not a person beyond his scope. He gets reward for that (good) which he has earned, and he is punished for that (evil) which he has earned. ‘Our Lord! Punish us not if we forget or fall into error”, Allaah said: I have granted that. “Our Lord! Lay not on us a burden like that which You did lay on those before us (Jews and Christians)” Allaah said: I have granted that. “Pardon us and grant us forgiveness. Have mercy on us. You are our Mawlaa (Patron, Supporter and Protector)” Allaah said: I have granted that. [al-Baqarah 2:286] Narrated by Muslim (126).
The scholars have stated that the one who does a haraam deed out of ignorance is not to be blamed.
Al-Nawawi said in Sharh Muslim (3/204):
If he forgot or was unaware that there was menses, or he was unaware that it was haraam or he was forced to do it, there is no sin on him and he does not have to offer expiation. But if he had intercourse with her deliberately, knowing that she was menstruating and that it was haraam, and did so willingly, then he has committed a serious act of disobedience which al-Shaafa’i described as a major sin, and he has to repent. End quote.
Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) said in al-Sharh al-Mumti’ (1/571):
Expiation is not required of the one who has intercourse with his wife when she is menstruating except when three conditions are met:
1-That he was aware (of the prohibition)
2-That he was aware of what he was doing
3-That he did it willingly.
If he was unaware that it is haraam or that she was menstruating, or he forgot, or the woman was forced, or the menses began during intercourse, then he does not have to offer expiation and there is no sin on him. End quote.
Since you did not know of the prohibition on having intercourse with a menstruating woman, there is no sin on you in sha Allaah, and you do not have to offer expiation.
But what every Muslim must do is strive to understand Islam and learn the rulings, morals and etiquette of sharee’ah, especially those that he needs for matters of worship, the rulings on marriage and buying and selling, and what he needs in his everyday life. He should not wait until he is about to do something and then go and ask or use the excuse of ignorance and lack of knowledge. There is the fear that the one who falls short in seeking essential Islamic knowledge may be sinning. The Prophet (peace and blessings of Allaah be upon him) said: “Seeking knowledge is a duty upon every Muslim.” Narrated by Ibn Maajah (224); classed as saheeh by al-Albaani in Saheeh Ibn Maajah.
And Allaah knows best.