I accidentally got my friend in trouble with his girlfriend.
How did you get him in trouble?
For some reason I thought it would be funny if I started to flirt with her.
You shouldn't do something that you know could cause a problem in someone else's relationship. You should apologize to both of them and explain to her what happened so she knows it wasn't your friend's fault. You really shouldn't flirt with someone who's in a relationship.
Meh, not like they will remain intact anyway.
Still, what you did was wrong. Don't do it again if you want to keep friends.