Wikipedia actually has an article dedicated to this phrase. It says: The earliest confirmed publication is the 1866 Dion Boucicault play Flying Scud in which a character knowingly breezes past a difficult situation saying, "Excuse me Mr. Quail, I can't stop; I've got to see a man about a dog." More @Wikipedia
Hover over any link to get a description of the article. Please note that search keywords are sometimes hidden within the full article and don't appear in the description or title.