To get to Pompeii, take the Circumvesuviana train from Napoli Centrale Station to Pompeii Scavi – Villa dei Misteri Station (around 30 minutes, 3 euros one way). From there, it's a 5-minute walk to the entrance. To get back to Naples, take the same train from Pompeii Scavi – Villa dei Misteri Station to Napoli Centrale Station. For Castel dell'Ovo, take Metro Line 1 to Toledo Station and then walk for around 20 minutes to the castle.
If you have more time, consider exploring other cultural sites in Naples, such as the Royal Palace of Naples or the San Carlo Theatre. If you have less time, consider visiting the Herculaneum archaeological site instead of Pompeii, or skipping Castel dell'Ovo if you want to spend more time in Naples' historic center.