This phrase was never uttered by the character in any of Sir Arthur Conan Doyle's written works. Though "Elementary," and "...my dear Watson." both do appear near the beginning of The Crooked Man (1893), it is the "...my dear Watson" that appears first, and "Elementary" is the succinct reply to Watson's exclamation a few lines of dialogue later. This is the closest these four immortal words ever appear together in the canon.
The association of this quote with the Sherlock Holmes character likely comes from the closing lines of the 1929 film The Return of Sherlock Holmes.
See "Elementary, my dear Watson" and other Famous Misquotations at http://www.2spare.com/item_92868.aspx