Praise be to Allah.
That does not matter and his fast is valid, because Allaah says at the end of Soorat al-Baqarah (interpretation of the meaning):
“Our Lord! Punish us not if we forget or fall into error”
It was narrated in a saheeh report from the Messenger of Allaah (peace and blessings of Allaah be upon him) that Allaah said, “I have done that.” And it was narrated from Abu Hurayrah (may Allaah be pleased with him) that the Prophet (peace and blessings of Allaah be upon him) said: “Whoever forgets that he is fasting and eats or drinks, let him complete his fast, for the One Who fed him and gave him to drink was Allaah.” (Agreed upon).
The same applies if he has intercourse because of forgetfulness; his fast is still valid according to the more correct of the two scholarly opinions, because of this aayah and this hadeeth, and because the Prophet (peace and blessings of Allaah be upon him) said: “Whoever breaks his fast in Ramadaan out of forgetfulness, he does not have to make that day up and he does not have to offer any expiation (kafaarah).” (Narrated and classed as saheeh by al-Haakim). This wording includes intercourse and other things that break the fast, if the fasting person does them because of forgetfulness. This is from the mercy, bounty and kindness of Allaah, for which we praise and thank Him.