How to Apologize

Best ways to apologize to a guy you broke things off with?  
I'll try to be brief:
I had sex with a guy I've been seeing. I met him online. He's the second person I've ever had sex with and I felt very ashamed, felt it was wrong, a mistake, too soon, so many feelings about this. It didn't help that when we were doing it, his phone lit up, and it was a friend of his who is a girl. He's said that she's just a friend. And I do believe him, but in that moment when we were having sex I felt so vulnerable. I had so many overwhelming feelings. The next day I just decided to end things eventho he really didn't do anything wrong. I just felt so afraid. I grew up Christian, and the one other person I've ever been intimate with I dated for 8 years. So me having sex with someone who hasn't officially asked me out, in such a spontaneous way, really scared me. I ended things yesterday, in a friendly way. And I know he felt sad. 
But now I have so many regrets. It's been 2 days after we had sex and my feelings and mind are much clearer. I really don't want to lose him. I want to apologize to him. But idk how. Tips?