Way back when, at local taverns, pubs, and bars, people drank from pint and quart-sized containers. A barmaid's (Jack reminded me of Shakespeare's 'Mistress Quickly') job was to keep an eye on the customers and keep the beer flowing. She had to pay close attention to remember who was drinking pints and who was drinking in quarts, in order to charge them for their drinks. From this, the phrase "minding your "P's and Q's " has been handed down to us.
On the other hand, many people believe the phrase actually stems from type foundries and printers, as illustrated in this comic:
I asked Jack what he thought and he said two things: 1) "Why are you writing about this? I'm a folklorist and who cares?" and 2) He suggested that the reference was actually about the male and female genitals, respectively [penises and quims]. He could be right. But I doubt it.