From an old printer's axiom. Back in the early days of printing presses, each line of text had to be set up one letter at a time. Since the letters in the press were reversed (so they'd print forward), the printmaker (or typographer) needed to be careful not to confuse one letter for the other. Reminding someone to "watch his p's and q's" means to pay attention to the details.
An alternate meaning for this idiom, and the one most commonly accepted as historical fact, dates back to the Olde English Pubs of yester-year. In order to remind the patrons of how much Ale or Mead they had drunk as the night progressed, the bartender would write on a chalk board (or the like) each (P)int and (Q)uart that had been consumed by each patron. It allowed said patrons to keep up with their tab, and prevented disagreements from happening between bar and patron. The term is actually correctly stated as "'Mind' your p's and q's."
at 2:56 AM on Jul. 23, 2010