If the thing they said (or wrote) is not too serious, tell the person who offended you "What you said (or wrote) has offended me. Please don't say (or write) that again."
If they offend you again, just stop communicating with the person.
If the offence (i.e. offending statement) was very serious I would immediately stop communicating with that person.
If the offender tries to communicate with you, don't answer that person. If you answer them, they will think that you are not really offended and they may do it again.
Good people try very hard not to offend others.