Praise be to Allah.
What your wife did of inserting the sperm of a stranger is a grave sin and a betrayal of her husband, and is introducing a child who is not his. What she must do is repent to Allah, may He be exalted.
What you must do is deny that this child is yours and not attribute him to yourself, because if you do not deny that he is yours, he may inherit from you and inherit from your relatives, and look at your mother and your sister, and your womenfolk will not observe hijab in front of him, and he may be alone with them, and all of that is prohibited.
There is no way to deny that he is yours except by means of li‘aan.
Ibn Qudaamah (may Allah have mercy on him) said: Accusing the woman of zina is of three types: obligatory, which is when he sees his wife committing zina during a period of purity in which he has not had intercourse with her – in that case, he must keep away from her until her ‘iddah ends, then if she produces a child six months from the time of committing zina and he can deny that it is his child, he must accuse her of zina and deny that her child is his, because in that case it is almost certain that the child is from the adulterer. If he does not deny that the child is his, the child will be attributed to him, and may inherit from him and his relatives, and they may inherit from him, and the child will look at his daughters and sisters, when that is not permissible. So he must deny that the child is his so as to avoid all of that.
If his wife admits committing zina and he believes her, it is as if he saw her do that." (Al-Mughni 8/71).
Ar-Ramli said in Nihaayat al-Muhtaaj (7/111): … He must deny that the child is his, otherwise if he keeps quiet the child will be attributed to him when he is not his child, which is not allowed, just as it is prohibited to deny a child who is his, for reasons that we will mention below, because there is a stern warning to the one who does that. Because of the evil consequences that result in both cases, these are regarded as very abhorrent major sins, and in fact they are referred to as kufr (disbelief) in the sound reports, even though some of the scholars said that it is only kufr if the doer believes that it is permissible; or the reports may be interpreted as meaning that these actions are a cause that will lead to kufr; or the word kufr may be understood in the sense of being ungrateful for Allah’s blessings.
If he came to know of her zina in the sense of being certain or thinking that it is most likely, he should accuse her of it and should engage in the process of li‘aan in order to deny that the child is his. Doing so is obligatory in both cases.
Otherwise, he may limit it to denying that the child is his through the process of li‘aan, because it is possible that the child is the result of a dubious marriage or a previous marriage. End quote.
For a description of li‘aan and how it is done, please see the answer to question no. 33615 .
In the process of li‘aan, you may limit it to denying that the child is yours and swearing by Allah four times that this child is not your child, and you should say on the fifth time: May the curse of Allah be upon you if you are lying.
The wife should not swear an oath at that point, if she admits her sin.
In that case, the child cannot be attributed to you and you are not obliged to spend on him. He should be given a random name, and his mother must take care of him; she may inherit from him and he may inherit from her.
And Allah knows best.