Mu'awiyah bin Suwayd (may Allah have mercy on him) said: I slapped a freed slave of ours and ran away. Then I came back shortly before Zuhr and prayed behind my father. He called him and called me, and said: Take retaliation from him. But he forgave. Then he said: We, the Banu Muqarrin, in the time of the Messenger (peace and blessings be upon him), had only one servant, and one of us slapped her. This reached the Prophet (peace and blessings be upon him), and he said: "Set her free." They said: They have no servant other than her. He (peace and blessings be upon him) said: "Then let them use her service, and when they no longer need her, let her go."
Muslim recorded it in the Sahih from Abu Bakr bin Abi Shaybah. In this there is something of an indication that the command to set free is not obligatory but recommended. And Allah knows best.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب النفقات / 15806