Yes, it is best to get the fact that you cheated on him off your chest now, and face the consequences, than taking the risk of your boyfriend finding out on his own.
I know that it is hard to come to terms with doing something this risky.
Nevertheless, by not doing it, you are carrying this burden and knowledge with you in your relationship.
That is difficult to do, especially as your feelings for your boyfriend get stronger and stronger over time.
Telling your boyfriend that you cheated is not solely about coming clean.
He has gone back to his cheating ex by virtue of his love for her, finally giving in to the emotions he had been suppressing from his past breakup with her.
Being a nice guy doesn’t preclude you from being cheated on by a girlfriend.
You have seen a cycle of this in your relationships.
Your past girlfriends cheated on you.
This is where you are choosing the wrong girls, or getting into relationships too quickly.
When you are going for the pretty girl all the time without any true concern for her character, you are doomed to repeat the same cycle, making the wrong choices in who you choose to date.