Should I use “of” or “in” in my sentence?
“German is the official language of/in Germany, Austria, Belgium, Switzerland, Luxembourg, and Liechtenstein.
The definite article ‘the’ makes the sentence incorrect. Belgium has three official languages: Dutch, French, and German; Switzerland has four: German, French, Italian and Romansh. Luxembourg has three: French, German, and Luxembourgish. Also, ‘of’ is the usual preposition for a official aspect of a state (language, capital city, currency, etc).
You can say
German is the official language of Germany and Austria, and
an official language of Belgium, Switzerland, Luxembourg, and Liechtenstein.
For completeness, you could include ‘the Italian province of Alto Adige (South Tyrol)’ in the second group.