What does Judaism have to say about the origin of the elements? I mean chemical elements like hydrogen, oxygen, gold, sulfur, etc. Is this discussed at all?
First off, see Wikipedia: Timeline of chemistry for the history of the development of our understanding of chemistry and the elements. See also Wikipedia: Timeline of chemical elements discoveries for the history of the discovery of particular elements; compare to the Timeline of Jewish history.
So if by 'Judaism' you mean classic texts such as the Talmud and early authorities, it's pretty clear that you will find nowhere in those works the modern notion of chemistry and the elements. So the short answer to your question is: nothing.
But to be a bit more specific, first regarding the particular examples mentioned: hydrogen and oxygen are clearly not mentioned in any context; sulfur, and particularly gold, obviously come up a lot in early sources, but again, not in the modern context of defining and distinguishing between the 'elements' on the 'table'.
As to the very concept of the elements: classic works are replete with references to, and discussions of, the classic, Aristotelian, four (or five) elements (and their relationship to hyle, particularly in terms of their origin), and following up on that lead may prove slightly helpful in satisfying your original question.
In conclusion, it should be noted that some have argued that the four elements discussed prolifically in Judaism are not to be understood in the context of chemistry at all, but rather physics: "Some hypothesize that they are four basic elements: positive, negative, antimatter, matter." (See also here).
This is getting into deep philosophy, but basically the Jewish concept is that G-d created everything but the world keeps going according to natural laws - also G-d's creation. The "created in stars" doesn't actually hold water since everything was created in a singularity in which the whole universe was in nothing. This is remarkably convergent with concepts such as Tohu veVohu and various concepts in Kabbalah.