An apology is asking forgiveness for any wrong deeds that one commits and realizes later. You ask for an apology or forgiveness when you deeply regret your actions and feel guilt.
One should be honest, realize your mistakes, and learn from them. Mistakes are nothing but lessons. A human being evolves by making mistakes and actually learning from them. Ask for apology when you feel you have done something wrong. You may not be pardoned all the time and your apology might not be even considered, but do make an apology if you feel like compensating for your wrong actions.