All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
If changing the family name results in attributing a person to someone other than his real father, then it is prohibited, given the reported stern warning in this regard. It was narrated that the Prophet, sallallaahu ‘alayhi wa sallam, said: “One of the worst lies is for a man to claim falsely to be the son of someone other than his real father.” [Al-Bukhari] The Hadeeth mentioned the word ‘father’ as a general term that includes the immediate (biological) father and the male ascendants up to all levels. Allah, The Exalted, Says (what means): {[It is] the religion of your father, Ibraaheem...} [Quran 22:78] Allah, The Exalted, called Prophet Ibraaheem (Abraham) our ‘father’ despite the long line of descent.
The woman in reference should strive to forget these matters that cause her anxiety and tension, move on with her life, and preoccupy herself with what benefits her with regard to her religion and worldly life. Having a relationship with a non-Mahram man is a serious evildoing, especially when she is married. Such sins are a reason for maximizing her distress, so it is incumbent on her to hasten to repent sincerely, give up the sin, regret what she did in the past, and resolve not to commit such a sin in the future.
If her husband mistreats her, he is violating the divine directive in the verse reading (what means): {…And live with them in kindness. For if you dislike them – perhaps you dislike a thing and Allah makes therein much good.} [Quran 4:19] She has the right to request divorce or Khul’ (divorce at the instance of the wife in return for compensation payable by her) if she is harmed by this situation. If she cannot obtain divorce or Khul’, she should fear Allah, The Exalted, and adhere to patience. She may seek the mediation of righteous people to reconcile between her and her husband and remind him that he should live with her in kindness or divorce her with kindness.
Allah Knows best.