I overheard my girlfriend saying she almost slept with her ex
Is she serious about the relationship with you?
She wants to have a stable relationship with me and I want to have a stable relationship as well.
If that's what you heard then you have the right to confront her about it and see if this will be an ongoing issue. You should not dwell on this because it will eat you up inside. If she loves you she should understand where you are coming from.
I have a plan: I am going to ask her to leave me if I can't do anything about this.
That sounds like a good idea. You can't expect to be with someone who has hurt you so much.