It's called verbal abuse.
There isn't always a clear distinction with whether someone is saying it maliciously or is trying to joke with you. As Steve said, it's usually the individual who allows the words to hurt them. I just say something right back, and I've learned that people who I thought were trying to hurt me with their words are actually cool with it when I say back something of the same caliber. Some people like to play by insulting each other, but some don't and so they take it personally.
However, I've had people say something to me as a personal attack, and that's when I turn towards them and say something that lets them know that they better give me the same respect that they want to receive. I've been working on not letting peoples' words strike me emotionally, so that I can calmly make an appropriate response, whether it may be a friend who's just joking or an ******* who needs to be out in his place.