Do both work?
I could only assume that both are grammatically correct...
As an example:
Let's say that there is a word that derives from a name, such as "sandwich" which was coined from a name of somebody.
But let's say that we want to ask the name of the person that it came from.
We would ask:
"Where does it come from?"
but I feel like that the phrase:
"What does it come from?"
is applicable and even more plausible when asking for the origins of words, as some might not have come from names or places.