You do not need a visa for entry and stay of up to 90 days if you are a citizen of Andorra, Australia, Brazil, El Salvador, Honduras, Canada, Israel, Japan, Monaco, New Zealand, South Korea, San Marino, or the USA. However, to stay longer than 90 days, a residence permit (see national visa) is required. This can be applied in Germany.
Citizens of all other countries outside the EU must apply for a visa before entering the country.
You can find more information on the homepage of the Foreign Office.
For longer stays over 90 days
You can find out which national visa you need online at the Foreign Office and also apply for it.
For short stays up to 90 days
You can apply for the Schengen visa online on the Videx platform of the Federal Foreign Office.
All currently valid visa regulations published
the federal government on the website of the Foreign Office