"There is no particular virtue in piling up words in your head that you are never going to need to use". (Some people might object to this on the grounds of ambiguity - that you are not going to use your head. But we can ignore that for now).
"words" is the direct object of "piling up". "in your head" is a prepositional phrase. In this case, the prepositional phrase can go before or after the noun "words".
Consider the following correct similar sentences:
"Don't keep in your desk books that you aren't going to use"
"Don't keep in your head words that you will never use"
"Why do you store in the garage things you should throw out?"
This is normal.
Student or Learner