It depends on your overall travel plans and schedule.
Are you flying in to Naples from somewhere else? If so, maybe it makes more sense to take a flight since you’re already at the airport.
If you’re staying in Naples for a while before moving on to Puglia, maybe it makes more sense to take the train rather than go back to the airport, back thru check in and security, etc.
Where are you going in Puglia? As far as I know, flights go only to Bari and Brindisi. If you’re going somewhere else, you’ll need to factor in the time and effort for that part of the transport as well, and maybe it’s easier/faster to just take the train the whole way.
When we visited Puglia last year, we flew ITA from Rome to Bari, which worked for us because we were on our way directly from the US and already at the airport. We hired a private transfer from Bari to our lodgings in Trani.
On the way back, we took the train because we were staying in Rome before flying home. The train was far more efficient for that leg of the trip.