Ah, this is a design approach issue. I do that opposite; I figure out the handful of spells I want them to use before I make the rest of the NPC.
If I make a caster specifically for an encounter, I'm choosing spells for the encounter and the NPC is there as a "how/why". Again, class as framework to save time. I choose a role for the Caster. To use 4e-isms, are they a striker-type blaster? Are they a Controller via illusions or mind-control to make PCs fight each other? Maybe they are a Defender via summons? Or the Controller who buffs their side?
Most fights only last a handful of rounds so you pick maybe 6 spells that fit the role/tactic specified and are within the design CRs spell level, starting at the highest level and working down. There won't really be that many and with a theme you can pick them pretty quickly. Often this tells you what class the NPC should be, especially within plot limits.
Then add a few "save myself" spells, one or two spells of a totally different role (illusionist with fireball, evoker with Programmed Illusion) as a wild card, and then finish off with semi-random utility spells you can pick just by name without worrying too much about the mechanics.