If your at the table, playing a TT do a little RP. If a bartender, have him cleaning a glass. Position yourself like they would, if an arrogant person, hold yourself up proper and talk like you are better than everyone. If PBP make sure to note different quirks of them. Make a note of the scotch glass in a bartender's hand that he is drying with a towel. How old is the character? Does he have gray hair? Perhaps a receding hair line? A distinct way of talking?
The biggest help that I have found for NPCs is nothing related to RPGs at all. It came from a book I found about how to write. "On Writing" By Stephan King was the book, and even if you don't like his work look into this one book. It will help you in your campaigns so much it's insane. The biggest article that stood out to me in the book was "Imagery and The Third Eye" By Stephan King. It sounded to me like it was written by a GM instead of a writer.
Second thought: It's a town. It has people. Sound simple? It's probably often forgotten. I've seen many GMs act like the NPCs are ghosts, or not there. When a player asks to get somewhere in town, have him pass someone, if he is in a hurry let him bump into someone. Have you ever seen someone in a hurry, who was practically running down a crowed sidewalk and not hit anyone? Have a merchant stop the players, and try to sell them something. Have some children playing tag run around and get in some of the players way, or knock into them and fall over. Have a crazy homeless man, or someone who is a big fan (if the heroes are famous) of the players, have him follow them and ask for something, or if he can adventure with them. Have someone who is the town drunk, or crazy. Have him hallucinate thinking the players are just his imagination.
In D&D especially people seem to overlook that adventurers just aren't common. It's expensive to be an adventurer, it takes years of training in some cases and its horribly dangerous. People just don't do it. So heroes would be strange in some towns, perhaps they are overly respected, or people look at them with disdain. Just make note of the mass amount of people who the players may never see again. No matter if they don't matter, they exist. Just like all those people with whom you will never meet in real life, they still exist, still have an impact on the world, and still live normal lives. I hope this helps you in your future campaigns! Feel free to mention anything you have found in your experience with NPCs what works and what doesn't and lets see if we can't make better campaigns with better NPCs.
Until the adventure ends!
Zuka Zamamee, the often forgotten NPC