by 1912, American English, first attested in baseball slang; as a type of music, attested by 1915. Perhaps ultimately from slang jasm(1860) "energy, vitality, spirit," perhaps especially in a woman. This is perhaps from earlier gism in the same sense (1842).
By the end of the 1800s, "gism" meant not only "vitality" but also "virility," leading to the word being used as slang for "semen." But — and this is significant — although a similar evolution happened to the word "jazz," which became slang for the act of sex, that did not happen until 1918 at the earliest. That is, the sexual connotation was not part of the origin of the word, but something added later. [Lewis Porter, "Where Did 'Jazz,' the Word, Come From?" http://wbgo.org Feb. 26, 2018]
Meaning "rubbish, unnecessary talk or ornamentation" is from 1918. Slang all that jazz "et cetera" first recorded 1939. Further observations from Porter's summation of the research:
"Jazz" seems to have originated among white Americans, and the earliest printed uses are in California baseball writing, where it means "lively, energetic." (The word still carries this meaning, as in "Let’s jazz this up!") The earliest known usage occurs on April 2, 1912, in an article discovered by researcher George A. Thompson, and sent to me courtesy of [Professor Gerald ] Cohen.
... By 1915, jazz was being applied to a new kind of music in Chicago. It seems to have been first applied to Tom Brown's all-white band, which hailed from New Orleans. This was followed by many printed references to jazz as a musical style.