I am wondering how to state this question and do not know which one is correct so is #1 correct or #2 correct or are they both grammatically fine?
Ferrous metals contain which element?
Which element do ferrous metals contain?
The standard word order for questions with an interrogative — who (whom), why, where, which, what, and how — places the interrogative or its phrase as the first element in a clause immediately followed by the verb:
What car did she buy and how much did she end up paying?
How did they manage to get here on time?
Who did she go with to the concert?
Where are they going?
Using declarative rather than interrogative word order, as in your example, yields a style typical of quizzes or quiz shows:
Lady Gaga teamed up with which famous crooner to sing "Baby It's Cold Outside" for a Barnes & Noble bookstore commercial? — TV Trivia Questions and Answers | TQN
Snoopy, from “The Peanuts”, is what breed of dog? — TV Trivia Questions and Answers | TQN
A Richter Scale reading of 7 is how many times greater than a reading of 6? — StudySoup.
Answers: Tony Bennet, beagle, x10.
This construction is perfectly grammatical and in either oral (pub quiz) or written contexts emphasizes the essential question in the sentence.
In other situations, using declarative word order — which often places the interrogative in final position — also emphasizes the words essential to the question, but with differing verbal stress or tone, may express any number of emotional responses to a preceeding statement, especially surprise or disbelief:
Statement: I hear Mark bought a Škoda.
Response: He bought a what?
Possible Context: I’ve never heard the word Škoda, much less that it’s the name of a make of car. Or with a different tone: What? Since I’ve known him he’s always driven a Ford truck. What made him change?
Statement: The Smiths went to Lisbon for three weeks.
Response: They went where?
Possible Context: The Smiths usually only travel to places where one or both of them speak the language. Or with a different tone: Wonderful! I’ve always wanted to go there. I hear the seafood is great!
Both are valid, but the pedant in me says both should be clarified to ask for the element in common. For example: Ferrous metals all contain which element? Which element do all ferrous metals contain?
To avoid a facetious but correct answer along the lines of "Ferrous metals can contain numerous elements. For example many ferrous metals contain carbon, while others contain manganese, chromium, and nickel."