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.
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.