4-5 nights in Oaxaca City sounds perfect! You will have space for a daytrip or two, which are very rewarding in that area.
I would advise against trying to visit Chiapas from Oaxaca. The roads are winding and a 12 hour bus is standard. Also, there's just way too much to do in the state. Better to keep Chiapas for a separate trip some other time.
I'm not a huge fan of Puerto Escondido town itself, but the beaches around it are my favorite in the world. If you wanna go upscale-ish, Hotel Escondido (member of Design Hotels) is just far enough from Puerto to feel isolated, and with definite rustic chic vibes. If you prefer a small, high quality but chill B&B, take a look at San Agustinillo, which has nicer beaches, is less crowded and more 'grown up' than Mazunte next door.
Note that the drive from Oaxaca City to the coast is awful - many hours and dangerous. Book a flight on a turboprop run by beloved local carrier Aerotucán (
Inicio - Aerotucan Aerotaxis de México), but book a few weeks in advance as it fills up.