Hasan al-Basri (may Allah have mercy on him) and Ibrahim al-Nakha'i (may Allah have mercy on him) said: "If a slave commits adultery with his wife before gaining freedom, then the hadd (prescribed punishment) is not applicable to him, but if he does so after gaining freedom, then he will be stoned."
Hadith Referenceسنن سعید بن منصور / كتاب الطلاق / 3342