I went through a period where I'd feel very bad after realising I had hurt someone's feelings by saying something inappropriate. Sometimes, I wouldn't even realise it until hours after I had made the comment.
In my childhood and teenage years, I was mostly oblivious to how some of the things I say were 'inappropriate'. Nowadays, I've arrived at a point where I take care to avoid saying things that either actually are inappropriate, or that could be construed as inappropriate. But even when something slips out of my mouth that hurts the other person's feelings, what I try to do is apologise immediately if I notice the person feels offended. If by then we're still not 'cool', then there's not a lot more I can do.
_________________
clarity of thought before rashness of action