You really can't go wrong with either one. Both have lovely white historic centers and a number of good restaurants, and train stations on the edge of town. However, Martina Franca is quite a bit bigger than Locorotondo, so perhaps would have the edge in having more options for dining, accommodations, etc. Also, Martina Franca has an enormous street market every Wednesday morning. No matter where you stay, try to get to Martina's market on Wednesday.
If you are going to be in Martina Franca in late July or early August, make sure to check out the Festival della Valle d'Itria. In addition to the Festival's classical concerts and opera performances (paid admission), there are many free concerts and events during that time.