Who was Abu ‘Afak, and why was he killed?
All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallahu ‘alayhi wa sallam, is His slave and Messenger.
Abu ‘Afak was a man from the Jews who used to abuse the Prophet, sallallahu ‘alayhi wa sallam, with his poetry and instigate the people against him, so one of the Companions, may Allah be pleased with them, whose name was Saalim ibn ‘Umayr, went to him and killed him.
The story is related as follows in ‘Uyoon Al-Athar fi Funoon Al-Maghaazi wa Ash-Shamaa'il wa As-Siyar:
"Then occurred the mission of Saalim ibn ‘Umayr Al-‘Amri against Abu ‘Afak, the Jew, in the month of Shawwaal in the beginning of the twentieth month after the Hijrah (migration) of the Messenger of Allah, sallallahu ‘alayhi wa sallam. Abu ‘Afak, was from Banu 'Amr ibn 'Awf. He was an old man of one hundred and twenty years. He was Jewish, and he used to instigate the people against the Messenger of Allah, sallallahu ‘alayhi wa sallam, and compose (satirical) poetry about him. Saalim ibn ‘Umayr, who was one of the great weepers and who had participated in the Battle of Badr, said, 'I vow that I shall either kill Abu ‘Afak or die trying to kill him.' He waited for an opportunity until a hot night came and Abu ‘Afak slept in the yard. Saalim ibn ‘Umayr learned of this, so he went to him, placed the sword on his liver and pressed it till it reached his bed. The enemy of Allah screamed and some of his followers rushed to him, took him inside his house, and interred him."
Allah knows best.
You can search for fatwa through many choices