The phrase minding one’s p’s and q’s means, simply, “being circumspect.”
The origins of the phrase most likely come from the two letters’ similarity to each other: Young children just learning to write often put a “p” for a “q” or vice versa.
Two other, more whimsical explanations should also be noted.
The first is that the phrase reminded bartenders in English pubs to correctly tally up their customers’ pints and quarts.
The second hails from Louis XIV’s France, when dance masters would suggest to their pupils they mind their p’s (pieds, meaning “feet”) and q’s (queues, meaning “wigs”) when dancing.