It really depends on the rules that you agreed for your time apart.
Unless it was explicitly stated that any sexual encounters wouldn’t be held against each other at a later date, I would advise that you’re better off keeping quiet. Bear in mind that some actions (like a throwaway one-nighter) can cause a disproportionate amount of distress.
AN EXCEPTION TO THE RULE… If you’ve slept with someone in your social circle (more common than you’d think). If you don’t trust those in the know to stay schtum, then you’re better off confessing before your girlfriend finds out. Studies from Penn State University found that women feel more let down by emotional cheating than the physical act itself, so make every effort to assure her that it was just a poorly timed, badly judged and purely physical dalliance – nothing more.