All perfect praise be to Allaah, the Lord of the worlds. I testify that there is none worthy of worship except Allaah and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
Touching the body of a non-mahram (permanently unmarriageable) woman without necessity is forbidden whether one is fasting or not. Nevertheless, this is much more forbidden for the fasting person. This is because fasting is a shield for the person against sins and Hell unless the person breaks such a shield by disobeying Allaah Almighty.
Ibn Al-‘Arabi, the Maliki scholar, said:
Fasting acts as a shield against Hell because the fasting person refrains from worldly desires while the way to Hell is paved and surrounded by worldly desires. To conclude, if the fasting person manages to abstain from the desires of this world, then such abstinence will protect him from hellfire in the Hereafter. [Fat-h Al-Baari 4/104]
Since the person in question has repented, we hope that Allaah will forgive and pardon him. This is because repentance erases previous sins.
Concerning the status of his fasting in the day in which he committed this sin, if he discharged semen or pre-ejaculatory fluid, then his fasting is invalid and he is required to make up for this day. If no fluid came out, then his fasting is valid and he is not required to make up that day.
Allaah Knows best.