The date of the coinage of mind your Ps and Qs is uncertain. The OED used to print a citation from 1779 but, as they have now withdrawn it from the online version of the dictionary, presumably they consider it unreliable.
So, the meaning, spelling and coinage of the phrase are all debatable.
Now we come to what is really uncertain - the derivation.
Nevertheless, it is one of those phrases that people know the origin of. When pressed all that really means is that the person they heard explain the origin had made a random choice from the list of proposed derivations below.
As no one knows the origin I'll just list those suggestions - mind your ps and qs derives from one of these:

- Mind your pints and quarts. This is suggested as deriving from the practise of chalking up a tally of drinks in English pubs (on the slate). Publicans had to make sure to mark up the quart drinks as distinct from the pint drinks. This is a favourite of folk-etymology. It is scuppered somewhat by the fact that drinks were rarely sold in quarts in English pubs.
- Advice to printer’s apprentices to avoid confusing the backward-facing metal type lowercase Ps and Qs. I've never heard any suggestion that printer should mind their Ds and Bs though and that has the benefit of rhyming which would have made it a more attractive slogan.
- Mind your pea (jacket) and queue (wig). Pea jackets were short, rough woollen overcoats, commonly worn by sailors in the 18th century. Perruques were full wigs worn by fashionable gentlemen. It is difficult to imagine who might be seen wearing both a pea jacket and a perruque.
- Mind your pieds (feet) and queues (wigs). This is suggested to have been an instruction given by French dancing masters to their charges. This has the benefit of placing the perruque in the right context - so long as we accept the phrase as being originally French. There's no reason to suppose it is from France and no version of the phrase exists in French.
- It is advice to children learning to write to take care not to mix up the lower-case letters p and q.
- It derived as reminder to children to be polite. This is supposed to be as a form of 'mind your pleases and thank-yous' - 'mind you pleases and kyous'. Pretty far-fetched that one.
"For Pete's sake!" Kimber, I think that everyone else is right about this, Pete is just a poor sod (well, maybe it's supposed to be St. Peter) whose name is evoked for no other reason than to avoid taking the 'Lords' name in vain. And my book contained no information about it. Which we shall see is a continuing theme in this post!

"Fill your boots." Ms. Eigler, this book just continues to disappoint! I did find this rather revolting little suggestion, however: I read one reference which suggested that the phrase originated with the English Cavaliers, who wore thigh-high riding boots. When drinking, rather than stepping outside to relieve himself, a Cavalier apparently had the option of doing so into his boots. Thus, "filling his boots" meant he could drink all he wanted without leaving the table. Gross, but is it true?
"It's a load of cod's wallop." I've heard this one before, LGS, and was wondering about it myself. But guess what, my amazing tome of information didn't have a word on this phrase either. But what I found was:
Entry revised for OED Online
codswallop
DRAFT REVISION Jan. 2006
slang.

"Bread and pull it." Blackcrag...I have to tell you, that sounds rather more crude than I can imagine your mother using! But then, I do have a knack of twisting things. Anyway, my perpetually useless little book didn't say a word about it, but I did look around a bit and found this conversation online:
Posted by Smokey Stover on June 02, 2004
In Reply to: Re: Bread and Pull it posted by ESC on June 02, 2004
: : My father, a man of Kent, used to use the phrase 'Bread and pull it' when asked what was for dinner/tea, whatever. Has anyone heard this phrase or know it's origin? Should the 'pull it' bit perhaps be 'poulet'? and if so, why bread and chicken?
: I'm from the U.S. and haven't heard that phrase. But my guess is that it was a joke. You may wish for bread and poulet for dinner. But all you get is bread and "pull it." As in pull off another hunk of bread.
Kentish folkways are out of my line, but it seems reasonable for a man talking about food to say "Bread and pullet." In the U.K., as in the U.S., a pullet is a young hen, and is usually considered quite edible, properly prepared. SS
"Now put that in your pipe and smoke it." Josie, I laughed when I read that! My grandma used to say that all the time, all the while looking very pleased with herself. You're right, it was a conversation stopper!
And guess what.
Nothing in the book. And nothing really anywhere. I mean, lots of places online had what it meant (not that it's difficult to figure out) but I couldn't find anywhere that explained where the phrase came from. If anyone knows....?
Here's a few that ARE in the book (which has sunk considerably in my estimation since I started this little project):
"Peeping Tom" Why do we call a person who makes a practice of peeping a "peeping Tom"?

"Hoodlum" How did ruffians come to be called 'hoodlums'? It's all due to illegible handwriting. In an attempt to coin a name for a San Francisco gang, a reporter took the name of the gang-leader, Muldoon, and reversed it making "Noodlum." The typesetter couldn't read his writing and set it up as "Hoodlum".
"Cheshire Cat" Where did we get the expression "grin like a Cheshire cat"? From Ireland. Cheeses once sold in Cheshire County, Ireland were molded to look like cats - and these "cheese cats" had very broad grins.
