In order to arrive from Naples to Rome by the means of public transport, it is possible to use the bus or the train. You can check here how to get to Naples from Rome by bus: Rome Naples: bus connections.
As for the train there are two options: Italotreno and Trenitalia . The average journey time is 2 hours.
You can check the timetable of Italotreno here (from 12.06.16 to 10.12.16)*:Italotreno Rome Naples
The first train to Napoli Centrale leaves from Roma Termini at 05.36, the last one at 22.40. The first train to Roma Termini leaves Napoli Centrale at 04.04, the last one at 22.50.
You can check the timetable and book the tickets on the official website of Trenitalia.