They are both grammatical, but only the second means what you mean. You might use 'my foreign language' in either of these cases:
- Everyone in a school has to study one foreign language (this is just an example); the school offers say German and French. (My daughter went to such a school. Her foreign language was German.)
- Someone 'collects' languages. Every year they study a new one. Someone might ask 'What's your foreign language this year?'
In the plural, the possessive can also be used to mean the number a person speaks: someone who knows I speak several might ask me 'Is Mandarin one of your foreign languages?'