The first thing you have to do as a person is admit that you did something wrong.
It depends on the offense, but it is almost always better to say I am sorry in person.
If the offense was severe, you may want to feel out the situation with an initial email or phone call. You might tell the individual that you regret what you said or did and give an initial I am sorry.
Be prepared to take some abuse when you give the apology. The person may not be readily accepting of your apologetic attempts.
If they do not respond initially and the relationship is worth saving, you will need to become very humble.
Do not be defensive. It is time to recognize you have done something wrong and need to make amends.
After the initial attempt, give the individual some time to think, and follow up with a phone call and additional apology.
If you live with the person, make sure to give them plenty of space. They will be more willing to accept an apology when they have had time to calm down.
When you apologize, be sincere.
Admit what you did, and admit that you know it was wrong.
Do not make excuses for your behavior and do not promise to change.
Let them know you are aware of your mistake, and ask them how you can make it up to them.
Let the hurt individual guide you to toward correcting your mistake.
Do not attempt to hug or touch the individual unless they initiate the intimacy.
After you have apologized take their cue. If they ask you to leave, leave. If they accept without hesitation, so be it. Accept whatever feedback they give you with an open heart.
Most of all, be careful what you say or do next time. One of the hardest things people do is have to apologize. It is better to avoid it if at all possible.
In the end, it is the right thing to do. You would want the same respect.