(It is argued) from this saying of Allah, the Mighty and Majestic: "And take in your hand a bundle of twigs, and strike with it, and do not break your oath." [Surah Sad: 44]
Abu Umamah bin Sahl bin Hunayf (may Allah be pleased with him) narrated from some of the Ansari Companions (may Allah be pleased with them) of the Prophet (peace and blessings be upon him) that a man was suffering from illness until he wasted away, and his skin clung to his bones. A slave girl came in to him; he became excited by her and had intercourse with her. Then he mentioned his incident to the Prophet (peace and blessings be upon him), and he (peace and blessings be upon him) said: "Gather a hundred twigs for him and strike him with them a single time."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الأيمان / 20030