When should you say sorry? Simple: whenever you do something wrong.
But is that what most guys do? Definitely not. Most guys will apologise for absolutely anything that makes a girl they're with upset. It's understandable, you just want to defuse the anger and apologising seems like the best way to do it. What's wrong with apologising for everything?
Well firstly you'll look like a pushover. Girls might seem like they want you to apologise, but they'll respect you less if you show you're willing to cave in for the most minor or nonexistent offense.
Secondly you're going to show her you're okay with drama. If you set boundaries of what she can and can't say she will learn what they are, and you'll have a much more peaceful more drama free relationship.
I remember my first girlfriend. Whenever she'd get even slightly annoyed at something, even something that wasn't really to do with me, I'd apologise or feel the strong urge to. As you can imagine, over time this got really tiring for her. Imagine having a little bitch for a boyfriend who just wants to placate you at every moment, who needs you to like him so much that he won't even stand up for himself. Needless to say, she ended that relationship pretty quickly.
The thing to keep in mind here is that frustration doesn't mean a loss of attraction. A girl could be frustrated at something you've done, maybe for no good reason. For example: a fwb once got mad at me because I described another girl as "attractive" in the process of telling a story. Now obviously, this really isn't a big deal. We all get insecure sometimes, but there's no need to become angry about it. If I had said sorry immediately and spent the next hour placating her, her anger would eventually subside. The problem is, I'd have lost some of her respect. Instead, I behaved in the sane way: as if it was no big deal. I happily talked to her about it, but I wasn't going to apologise or beat myself up when I knew I wasn't in the wrong. It took longer for her to calm down, but eventually SHE apologised for being emotional.
This is the pattern you'll notice a lot if you practice apologising less in day-to-day life (because this doesn't just apply to girls). When you DO apologise, it will actually mean something. And in the meantime, you're maintaining your integrity. Girls might get annoyed at you now and then, but by refusing to degrade yourself over any little thing, they'll respect you much more.