The idea that you can't interact casually without risking personal offense is just a knee-jerk reaction. If restricting work conversations about personal appearance, sex, gender, race, religion, rape, etc. is equivalent to eliminating all personal interactions, your conversations must be quite impoverished.
Telling you that your jokes are offensive would indeed be harassment---if you worked at a late night show or another joke-telling profession! Otherwise, no, telling you that your jokes are offensive is in fact not a form of workplace harassment.
Also, you might want to reflect on why making friends, telling jokes, laughing, and enjoying life requires you to say racist and/or sexist things at work.