What happens if relations were had after period is over but before immersion in mikvah for the man and women, and how to rectify mistake?
The way to rectify this mistake, although a serious one, is by doing three things. Firstly by feeling remorse about the mistake, which you have already done by the fact that you are reaching out for help in getting rid of the sin. Secondly, you have to confess to H-shem, and say “H-shem, I am sorry that I sinned and had relations with a (or while I was a) niddah”. Third is to do something concrete to make sure that this mistake will not repeat itself. I would suggest that you learn or review the laws of niddah together with your wife, in order to strengthen your awareness of the pertinent laws that you need to know. You should keep a calendar in order to help you keep track of what day the woman has to go to the mikvah, and what has to be done on which day. This is something concrete that will help you from making such a mistake again.
If you need a suggestion of book to buy, please let me know.
Best Wishes :