Pompeii is huge. Everyone - myself included - underestimates the size of the site and many underestimate the physical labor of walking on ancient stones in the summer heat. And doing them from Rome adds the travel on both ends extending the day. I don't think it is reasonable to do both in one day.
For either site you would need to get to the main train station - Roma Termini - and there many buses that run to the train station from your area: 40, 85 etc. I would check with your hotel and/or use Google Maps or CityMapper app for these details. You can just tap your credit card on Rome buses - note each person needs their own card for their own ticket.
From Rome to Naples is just over an hour on the fast train and you can then take rickety Circumvesuviana train to either location. Note that not all trains stop at Herculaneum - Ercolano Scavi on their schedule. But all trains stop at the Pompei Scavi - Villa dei Misteri stop. The Pompeii exit is right an the park entrance but the Herculaneum stop is a walk downhill to the sight.
Fast train tickets are much cheaper purchased in advance so if you can commit to a date and time to start off you should at least buy your outbound ticket. If you purchase a return ticket it will cap your time so you'll either need to hurry back or possibly wait at the Naples train station for your train. There are good food options at the train station. If you buy "day of" full price tickets will cost you 48e a person each way versus 22e purchased early so it makes a difference. Coming back you can trade cost for time and the Intercity train is about an hour longer and costs about half as much and the regionale train is slower than that but 13e.
I highly recommend the Trentilia app for checking and buying train tickets.
You might also arrange a guide in Naples who provides transportation which will cut out the Circumvesuviana step. There are no official guides at Pompeii but there are plenty of guides hanging around looking to get hired.
Herculaneum is more intimate because of the size and preserved nature of the site and feels "enclosed" because of the city and walls surrounding it. Pompeii is a large city that sprawls and would take multiple days to see it all. Most people concentrate on Pompeii but both sites have their appeal. If you can squeeze in the Museo Archeologico Nazionale di Napoli while you are in Naples it is highly recommended and adds tons more information than just the sites.
Have a great trip,
=Tod