This expression has often been translated as "mind your manners" or "mind your pleases and thank yous." It is possible that the expression is an abbreviated term for minding one's manners as well, shortening pleases to p and thank yous to q, for the sake of a familiar expression.
The expression can either be written as Mind your Ps and Qs or Mind your P's and Q's. The use of an apostrophe after a single capital is not required by traditional rules of grammar but is used by some to aid in clarity.
A second origin story comes from early printing presses. Printers placed individual letters on a typeset to print a page of text. The letters were reversed, making it easy to mistake Ps and Qs in setting the type. A reminder to stay watchful of the details could have come from this time as well. In a similar setting, this expression has been attributed as an adage for teaching children to spell. This second story has been disputed, however, as it can be just as confusing in typsetting or handwriting to confuse b and d.
Other origin stories, some considered "fanciful", could come from French instructions to mind one's pieds (feet) and queues (wigs) while dancing. However, there is no French translation for this expression. Another origin could be to sailors in the eighteenth century to pay attention to their pea (coats) and queue (wigs).
A possible origin or at least similar expression comes from seventeenth-century slang. "P and Q" meant "prime quality" or "highest quality." It has also been seen as "pee and kew," though it is unclear what either literally stand for. It seems also unlikely that this is the direct origin, for the common expression is not "mind your pq.
Most examples of the expression in use today come from print sources. David Covey's book on improving quality and success in a consumer-driven world is titled Mind Your Ps & Qs, using key phrases starting with "p" and "q" to illustrate his points. Edward Makhene has written a philosophy book titled Mind Your Ps and Qs: Philosophy Goes to High School with the goal of having students study and analyze society's common-held beliefs and their validity. Brief origin stories can be found in linguistics books, like Karlen Evins' I Didn't Know That or David Wilton's Word Myths. The expression can be found used by journalists in headlines as well, often based upon the "manners" definition, as can be seen on MSNBC
or
http://www.dictionary.com