The best time of year to visit Naples would have to be between early spring to mid-summer, and September and October.
The reason for this is that Italy sits in the middle of the Mediterranean Sea, which is far enough south that it can get quite hot during the spring and summer months. Anytime you visit the south of Italy it is going to be fairly warm, except for the winter months when it can get relatively cold. The best months to visit are between March and June. It is not quite cold anymore, and the temperature has risen to hover around 20-25C (70-85 degrees farenheit). This is a very comfortable temperature, especially if you will be doing a lot of traveling in the countryside and doing outdoors activities. You can still visit late into the summer, but by then the heat can be quite overwhelming.
Keep in mind that certain weeks during the spring and summer can be very chaotic, such as the week of the summer solstice. Many people get time off during this time period and go away for holiday. If you are going in the winter, remember that the week of Christmas is a very busy week, and many tourists will be in Italy because they will be visiting the Vatican. Easter is also a major time for people to travel to Rome to visit the Vatican for it's religious festivities.
August is not a time to visit Italy. Besides being incredbly HOT, most of the country is on holiday. Italians spend the month of August on the beach relaxing. So if you planon being at the beach it is very busy. Most tourist locations still have their stores and businesses open, and Naples is very quite. With most of the people in the city being away for their vacation the city is practically empty. Naples is not as busy and chaotic with tourists as Rome or Venice is. So going to Naples during the summer will be hot but you would not have to worry about crowds.