I often do NPCs on the fly too. As an example, my last city guard game had the players tracking down some criminals that had escaped prison. One was a half-elf local to the city, so one of my players decided they'd track down the criminal's family and see whether they knew where he was hiding.
Cue me being caught without any prepared material. So, time to improvise!
First step in any improvisation is to delay so you have time to plan. I do this by playing up the local geography. I've already researched a bit of the background of the city, and I know a few facts from the setting. So I describe the layout of this residential district by framing it with the local tax law that states that residents must pay road access taxes for any building that exits onto a street. Thus, the building they're seeking is buried in a maze of impromptu back alleys and pathways that the locals have created to avoid this paying this tax.
Since their mission is on a time limit, they don't want to spend hours searching for this address. I've already decided the weather is pouring rain this particular day, so when one of the players says they want to find a local child to lead them to the address, I immediately grab the opportunity for a pop culture reference. Cue a small boy running down the flooded street, yellow raincoat flapping behind him, as he follows his paper boat along the gutter, racing towards a drain that empties into the city sewers. Great way to pad a few more minutes of planning time while my players start referencing balloons, clowns, and various other movie quotes.
Eventually they get back on track, and by now I have a game plan. The child happily leads them to the address they seek, and the door is answered by an elven man. He leads them inside his tiny flat, a single common room with a bedroom screened by a hanging cloth. They chat with him, he warily answers their questions, and cue coughing coming from the adjacent bedroom. Their suspicions are aroused, thinking this might be their escaped convict. Instead, I have the man say his wife is sick with illness. He claims it's some form of curse that the local healers cannot cure, so he spends most of his day caring for his sick wife. He says he hasn't seen his son in many years, and my players confirm his words seem genuine with some decent Sense Motive checks.
At this point, they leave and go on with their investigation. I'm actually rather upset by this too, since I had a great story hook I'd developed. See, in my few minutes planning, I'd decided that the wife of this man, should the players insist on speaking with her, turn out to be his second wife after the mother of the escaped prisoner died. If they'd searched her room, they'd have had a chance to find a secret shrine to a god of assassins and poisoners, and potentially discovered this elven man was a serial killer that had married and poisoned numerous wives over his many hundreds of years of life.
Alas, it wasn't meant to be.