1707 as a direct phrase, but implied much earlier.
"Abide þou þef malicious!
Biche-sone þou drawest amis
þou schalt abigge it ywis!"
["Of Arthour & of Merlin," c.1330]
"Probably the most common American vulgarity from about the middle of the eighteenth century to the middle of the twentieth" [Rawson]. Abbreviated form
SOB from 1918. Mencken, complaining of the tepidity of the American vocabulary of profanity, writes that the toned-down form
son-of-a-gun "is so lacking in punch that the Italians among us have borrowed it as a satirical name for an American:
la sanemagogna is what they call him, and by it they indicate their contempt for his backwardness in the art that is one of their great glories." ["The American Language," 4th ed., p.317-8]