Sahih al-Bukhari, Volume 3, Book 46, Hadith 731 (USC-MSA) ⓘ
Narrated Abu Huraira and Zaid bin Khalid: The Prophet said, "If a slave-girl (Ama) commits illegal sexual intercourse, scourge her; if she does it again, scourge her again; if she repeats it, scourge her again." The narrator added that on the third or the fourth offense, the Prophet said, "Sell her even for a hair rope."
حَدَّثَنَا مَالِكُ بْنُ إِسْمَاعِيلَ، حَدَّثَنَا سُفْيَانُ، عَنِ الزُّهْرِيِّ، حَدَّثَنِي عُبَيْدُ اللَّهِ، سَمِعْتُ أَبَا هُرَيْرَةَ، وَزَيْدَ بْنَ خَالِدٍ، رضى الله عنهما عَنِ النَّبِيِّ صلى الله عليه وسلم قَالَ " إِذَا زَنَتِ الأَمَةُ فَاجْلِدُوهَا، ثُمَّ إِذَا زَنَتْ فَاجْلِدُوهَا، ثُمَّ إِذَا زَنَتْ فَاجْلِدُوهَا، فِي الثَّالِثَةِ أَوِ الرَّابِعَةِ بِيعُوهَا وَلَوْ بِضَفِيرٍ " .
also referenced under: Book 49, Hadith 39 (In-Book) & Hadith 2555 (DarusSalam)