Also check out the basque region, San Sebastian an obvious choice, big enough to have spend a good time off the bike, small enough (it felt like) to be out on the bike quickly. It also doesn't get crazy south Spanish hot;
Barcelona has been mentioned, great for partying, the sea is close, but like any major metropolis, cycling might be a bit ore complicated, if you are staying inside the city.
I also had good times in Madrid, Salamanca, and Burgos. Granada is a nice place to visit and Sevilla is also awesome if you want to enjoy the nightlife but in the summer (July August) it gets incredibly hot, which might hurt your cycling performance. Siestsas are a prerequisite...