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 is His slave and Messenger. We ask Allaah to exalt his mention as well as that of his family and all his companions.
First of all, it should be mentioned that fornication is one of the great major sins, and whoever committed it is obliged to sincerely repent to Allaah immediately and should not inform any one about it. Allaah Says (which means): {And come not near the unlawful sexual intercourse. Verily it is a faahishah (i.e. anything that transgresses its limits; a great sin) and an evil way (that leads one to Hell) unless Allaah forgives him/her.}[Quran 17:32]. Therefore, whoever committed this sin is obliged to repent sincerely to Allaah fulfilling the conditions of a true repentance; for details refer to Fatwa 87903. For more benefit, please refer to Fataawa 91225 and 88192.
As regards your question, when a person is in a state of sexual defilement, he is obliged in religion to perform Ghusl (i.e. a ritual bath). Allaah Says (what means): {If you are in a state of Janaaba (i.e. had a sexual discharge), purify yourself (bathe your whole body).}[Quran 5:6]. Allaah did not differentiate between the performance of Ghusl to when a person is in a state of sexual impurity in a legal way or to when he is so in an illicit way. If a person who got in sexual defilement in a legal way is obliged to perform Ghusl, then it is more appropriate for a person who got in sexual defilement in a forbidden way to perform Ghusl. Therefore, the wisdom is that Allaah ordained us to do so. For more benefit, please refer to Fataawa 82245 and 91485.
Allaah Knows best.