The consensus on the web is that 'pardon my French' is an expression used when one is compelled to use obscene language despite the presence of listeners who might be offended.

According to Issue 58 of Take Our Word For It (October 25, 1999) this phrase was first seen in Harper's Magazine in 1895.

Note that the association between the French and vulgarity is even older than this. 'French Pox' and 'the French Disease' both refer to genital herpes and 'French-sick' was a synonym for syphillis -- all of these date back to the early 16th century. Also consider French letter, French kiss and French novel.

English is notorious for using nationalities in a derogatory manner. Consider Indian giver, French leave, Mexican standoff, or Chinese fire drill.

Source:

Take Our Word For it Issue 58:
http://www.takeourword.com