I feel like I say the wrong thing all the time...I try not to worry about it, but it's my biggest issue with socialising. And I know it is mostly (or always) in my head. E.g. recently, I had a conversation with someone who is going through a difficult patch and came away feeling terrible, sure I had put my foot in it and made them feel really awful. I spent days beating myself up over this. Then I received a card from this person, thanking me for taking the time to talk to them & explaining how much the conversation had meant to them.
I hope this doesn't sound like I am sharing this to try to make me sound good, I just hoped it might encourage someone else who feels the same way as me to realise that you don't necessarily come across as tactless to others as you do to yourself. So while you are thinking you came across as really insensitive, the person you spoke to may be grateful you took the time to talk to them.
I think those who are most likely to do the wrong thing are those who never question their own behaviour - hopefully, those of us who are always doubting ourselves will be more self aware and maybe less likely to hurt others by thoughtless comments?