Madam, abbreviated commonly as ma'am, is a respectful and formal address to females. The word originates from the French madame (with emphasis on the second syllable), which means "my lady". The word has spread into many other languages, most notably English.
Calling a person madam in English (accent on the first syllable) usually refers to a woman of considerable position or power – as in Madam Secretary or Madam Chairperson. The proper context is important as the title of Madam also refers to a female manager of a brothel.
The simplified ma'am is a formal way to address a female superior or an adult female customer, similar to sir for men. While men tend to have no problems with being called "sir", women often dislike being called "ma'am" because it makes them feel old, and they consider that a negative thing. For some women, being called ma'am for the first time is a dreaded milestone indicating the end-point of their youth. This noteable difference between the terms "sir" and "ma'am" has its roots in society's biases towards gender and age. As a consequence, the term ma'am has declined in popularity and is now associated with a matronly, middle-aged or elderly woman.
In the United States, ma'am is more widespread than in other English speaking countries.
The humorous phrase "Wham, bam, thank you, Ma'am", a glib reference to casual sex between relative strangers, dates back to the 1940s. There are also two series of pornographic sex videos called Wham Bam Thank You Ma'am and Stick It To The Ma'am.
In BDSM and spanking
In BDSM, ma'am is a common address to a dominatrix or the dominant in a household. In domestic settings, submissive persons often say, "Yes, ma'am" or "No, ma'am" to their Domme in a respectful manner. In spanking, ma'am is often the female spanker being addressed by the spankee or a female superior in any number of dominance scenarios.
Femdom magazine and books
Please, Ma'am: Erotic Stories of Male Submission and Yes Ma'am: Erotic Stories of Male Submission (2008), both edited by Rachel Kramer Bussel, are collections of Femdom short stories.