look at the "Europe port chat" for Pompeji. There you will find a lot of advices. You can take thr train Circumvesuviana from Naples frsit to Peompeji Scavi. Than back direction Naples to Ercolano (Herculaneaum). You will need about three to four hours least for Pompeji and two to three hours for Ercolano.