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 is His slave and Messenger.
The general rule is derived from the meaning of the Hadeeth, "I was not been sent as a curser; rather, I was sent as a mercy." [Muslim]
Faydh Al-Qadeer reads:
"I was not been sent as a curser; rather, I was sent as a mercy to those whom Allah wanted to bring out of disbelief to faith, or (I was sent in order) to bring the people closer to Allah and to His Mercy, and not to keep them away from it." [End of quote]
So, the principle of the matter is to be kind to people and wanting to guide them, and not to curse them. Allah Says (what means): {And We have not sent you, [O Muhammad], except as a mercy to the worlds.} [Quran 21:107]
What was reported that the Prophet cursed some people or some categories of people, such as the woman who do hair extensions (connecting artificial hair to the original hair) and the one to whom this is done; these narrations do not contradict the Hadeeth that reads "I was not sent as a curser."
The word "curser" is used in a form reflecting exaggeration in cursing, and the meaning is that I was not sent as a person who frequently curses, so it does not contradict cursing a few people who deserve to be cursed.
Some scholars said that the curse (stated in some of the narrations) is not a supplication to the effect of cursing from him; rather, the Prophet was informing that Allah has cursed them, as stated in the footnote of As-Sindi on Sunan Ibn Maajah.
Allah knows best.