Anyone who was looking out their window on the flight into Rome knows that it is not far from the Mediterranean at all. In fact, the beach at Ostia is the go-to for Romans when they want to relax and cool off, mostly because it is so close and easy to get to.
Getting there with public transportation is really easy. What you need to do is take the Metro B to Piramide, which is also a train station, and take the train line that goes directly to Ostia. Once you get there you can either walk to the beach or take one of the buses a couple stops, nothing too difficult.
It's the same type of train as the metro and takes about 45 minutes (no worse than most normal journeys within Rome on the metro). According to the article linked to above, they are stepping up traffic to the beach on this train line, as well as offering a bus (although I would recommend the train, just for it's simplicity).