If something you've done has caused pain for another person, it's a good idea to apologize, even if whatever you did was unintentional. ... Basically, if you care about the other person and the relationship, and you can avoid offending behavior in the future, an apology is usually a good idea.
How do you know when you should apologize?
You need to apologize when you've done something wrong. That's it. Not when someone's mad at you for no reason, not when you want to take the blame just to diffuse a confrontation. When you've messed up and if you've hurt someone, that's when you should apologize.
Should I apologize if I don't mean it?
When the other person has demanded an apology, and you're just apologizing to avoid disapproval. ... Apologies don't mean anything unless you truly plan on changing your behavior, which might mean getting help for the problem. When the apology is a way to absolve you of responsibility for your actions.