Herculaneum, Pompei and Paestum in the same day is just not feasible.
What you can do is to visit Pompei and Herculaneum, then heading to Paestum just for one of the nice rural-setting hotels around Paestum (pick something close to the ruins, not by the sea, i.e. walking distance). Even though, arriving after sunset at Paestum and going to the hotel would require a bit of advanced-planned logistics.
To complicate things further, the railway station in Pompei that leaves you closest to the ruins entrance (Pompeii Scavi/Villa dei Misteri) is not on the same railway that connects Napoli to Salerno (and Paestum further south), so it would require that you go from Napoli to Pompeii on the main rail line, stopping at Pompei FS (the main town station), walking to the other ruin area entrance, leaving your bags there and then going back to take a slow train to Salerno and Paestum.
Summing it all: unless you have one extra night, I'd cut out Paestum, pick a hotel in Sorrento or Vico Equense, and head to either village after your tour to Herculaneum and Pompei. Then you catch a ferry from Sorrento to Capri. You really need two nights between Rome and Capri to visit the three sites.
Here is an alternative arrangement if you have one extra night:
Take a train from Rome to Salerno (most of it will be high-speed until Salerno, avoid slow and much longer routes) early in the morning. Set yourself up at a hotel near the train station (there are some comfortable and affordable options and the area has been renovated/improved a lot from its decay of 10-15yrs ago). Leave the bags and catch a train to Paestum. Visit Paestum in the afternoon (the ruins are just 300m from the train station). Take a train back to Salerno.
Take a train to Pompeii FS, walk (~12-15min) to the main entrance of Pompeii. Visit the ruins (they are huge), then exit via Porta Marina (the other entrance near Villa dei Misteri, served by EVA trains to/from Napoli and Sorrento). From this other train station (Pompeii Scavi/Villa dei Misteri), take a short train ride to Ercolano Scavi. Visit the site. Once again, walk to the other station in town (Ercolano FS), where you catch a train back to Salerno.
After a good night of sleep, take the one of the many ferry options to Capri from the Salerno dock. This trip will also give you a very nice sea view of the Amalfi coast!
For this to work you will need several train trips
Trenitalia - Rome-Salerno (buy in advance for cheap fares, beware of cheaper but much longer routes, buy the high-speed 'Freccia' routes)
Trenitalia - Salerno-Paestum (regional trip, fixed prices, no reservation)
Trenitalia- Paestum-Salerno (regional trip, fixed prices, no reservation)
Trenitalia- Salerno-Pompeii FS (regional trip, fixed prices, no reservation)
EVA (former Circumvesuviana) Pompeii Scavi-Ercolano Scavi (regional trip, fixed prices, no reservation)
Trenitalia- Ercolano FS-Salerno FS (regional trip, fixed prices, no reservation)
Hope I helped give you some alternatives. The train trips are all very easily done, all the regional routes have 1 to 4 trains per hour during daytime. You can buy regional tickets in loco. The one from Rome-Salerno, in advance, online.