Ah, the “shave and a haircut, two bits” ending! From what I found it was first used over 120 years ago (with no lyrics) in an 1899 song by Charles Hale, called “At a Darktown Cakewalk.”
Your pitches are correct but the rhythm is actually this:
The second beat can either be two 8th notes as shown or three 8th note triplets (your 2nd-4th notes). The Ab (G#) and A on beat 3 are also variations with the Ab usually being used with the triplet version. Both versions are widely used.
In 1914 Jimmie Monaco and Joe McCarthy released a song called “Bum-Diddle-De-Um-Bum, That's It!” This lyric fits the second beat triplet version of the melody.
Here is a wiki article with lots of info on this musical phrase, enjoy!