I usually apologize by stating that I was unaware that I hurt/stepped on toes etc. Then state that the truth, that I never intended it that way and that I am very sorry to have caused them pain/or sorrow, that I will bear in mind the next time we are talking about that subject or issue.

Most people are unaware they hurt others, so I always take it very seriously if someone tells me that a comment or statement bothered them.