It is narrated from Sayyiduna Samurah bin Jundub (may Allah be pleased with him) that the Messenger of Allah (peace and blessings of Allah be upon him) said: "Whoever kills his slave, we will kill him in retribution, and whoever cuts off his (the slave's) nose, we will cut off his nose." The narrator said: Then Hasan (may Allah have mercy on him) forgot this hadith and used to say: A free man will not be killed in retaliation for a slave.
Brief Explanation
(Commentary on Hadith 2394)
If a slave kills a free Muslim, then by consensus that slave will be killed in retaliation. However, there is a difference of opinion regarding whether a free Muslim should be killed in retaliation for a slave.
Some scholars have said: a free person will also be killed in retaliation for a slave. The second group says that if a free man kills someone’s slave, he will not be killed, as has been narrated from Hasan al-Basri rahimahullah. And if an owner kills his own slave, then by consensus the owner will not be killed in retaliation for his slave or slave-girl. Imam al-Nakha’i rahimahullah has differed on this matter, which is not correct; he has used this hadith as evidence: «مَنْ قَتَلَ عَبْدَهُ قَتَلْنَاهُ.» but the majority of scholars have said that this hadith is weak or abrogated. The correct view is the first one.
(And Allah knows best).