Praise be to Allah.
The fasting person must refrain from intercourse during the day in Ramadan, and if he does it then he must offer a severe expiation, regardless of whether intercourse took place in the front or back passage, with a man or a woman.
If it was in the back passage of a man, then this is sodomy, which is a grave major sin, for the one who does that has committed two grave major sins: sodomy and deliberately breaking the fast during the day in Ramadan.
What he must do is repent to Allah, may He be exalted, offer expiation and make up that day’s fast.
If he has delayed making up that day, then in addition to the above, he must give a poor person a kilogram and a half of rice or similar foodstuff.
It says in al-Iqnaa‘ (1/312): If he has intercourse during the day in the month of Ramadan, in the front or back passage, with a human or otherwise, living or dead, whether he ejaculates or not, then he must make up the day and offer expiation. End quote.
See the answer to question no. 190411.
Expiation must be offered by the one who does it and the one to whom it is done.
Ignorance of the required expiation does not mean that it is waived. The basic principle in such cases is that one who is aware of the prohibition on the action but is unaware of the punishment is not excused, as the Sahaabi who had intercourse with his wife during the day in Ramadan was unaware that he had to offer expiation, but that was not an excuse that would waive the punishment.
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) said:
If someone were to say: Wasn’t the man who came to the Messenger (blessings and peace of Allah be upon him) unaware [of the ruling]?
The answer is that he was unaware of what was required of him, but he was not unaware of the fact that it was prohibited, and that is why he said, “I am doomed!”
If we say that ignorance is an excuse, we do not mean ignorance of the consequences of this forbidden action; rather what we mean is ignorance as to whether this action is forbidden or not.
Hence if someone commits zina because he is unaware of the prohibition on it, such as if he lives in a non-Muslim country and is new in Islam, or he lives in a remote wilderness where people do not know that zina is forbidden, then he is not to be subjected to the hadd punishment. But if he was aware that zina is forbidden but was not aware that the hadd punishment for it is stoning, or that the hadd punishment is flogging and banishment, then he is to be subjected to the hadd punishment because he transgressed the prohibition. Ignorance of the consequences of a forbidden action is not a valid excuse, whereas ignorance as to whether the action is forbidden or not is a valid excuse.
End quote from ash-Sharh al-Mumti‘ (6/417)
See also the answer to question no. 20237.
In order for the expiation to be required, it is stipulated that the tip of the penis– where circumcision is done – should penetrate the private part. If this level of penetration occurs, the same rulings come into effect that result from full intercourse.
Ibn al-Qayyim (may Allah have mercy on him) said: The circumcised area of the man is the round area at the tip of the penis. This is what brings the rulings into effect if it disappears into the private part; more than three hundred rulings result from that. One of the scholars compiled them and the number reached four hundred less eighty [i.e., 320] rulings.
End quote from Tuhfat al-Mawdood bi Ahkaam al-Mawlood, p. 152
If the tip of the penis did not disappear as described above, or there is some doubt concerning that, then expiation is not required, because rulings do not become obligatory when there is doubt. But you must repent from having done a forbidden action.
And Allah knows best.