Naples if you plan to visit the Amalfi Coast and Matera (alongside all the other places that the regions of Campania and Basilicata offer). Bari if you will spend your time in Puglia and the surrounding areas. From Bari, you can easily reach the Gargano area. Besides, the city is decently connected via train to Lecce - the starting point for traveling in magical Salento. If you have a rental car, you can easily visit Puglia from north to south.