The Prophet ﷺ said, "The child belongs to the bed, and for the fornicator is the stone."
حدثنا هشام بن عمار قال حدثنا سفيان بن عيينة عن الزهري عن سعيد بن المسيب
أن النبي ﷺ قال الولد للفراش وللعاهر الحجر
Muslim, Radaa, chapter "The child belongs to the marriage bed, and for the adulterer is stone," hadith no. 1458, from the hadith of Sufyan, with the disagreement among the narrators regarding it mentioned.