(covers information from several alternate timelines)
In the mid-20th century, after its defeat in World War I, Germany was a bankrupted and comparatively small nation. After the fascist Nazi Party came to power under the leadership of Adolf Hitler, Nazi Germany or Third Reich rose to prominence and almost gained global domination in World War II. Germany was ultimately defeated in the war, which had to be achieved with great sacrifices. According to historian John Gill, it was the most efficient state in Earth history. (TOS: "Patterns of Force")
In an alternate World War II, Germany, aided by the Na'kuhl, had conquered France, Belgium and the Netherlands, fought in Africa and Russia (capturing Moscow), and was able to launch a successful invasion of England and, by 1944, had taken much of the eastern coast of the United States of America. (ENT: "Storm Front")
In another alternate timeline, created by Leonard McCoy saving Edith Keeler, the United States delayed its entry into World War II. Germany thus could complete its heavy water-experiments, develop the atomic bomb and use V-2 rockets to deliver them, conquering the world. (TOS: "The City on the Edge of Forever")
Germany and the Germans have almost exclusively been mentioned in the context of World War II, either its historic version or in alternate timelines where Germany was more successful.
The country's flag, used before and after the Nazi era, was described in "The Last Outpost" and appeared in several graphics related to 21st century spaceflight; Data described it as "red, black and gold", though the correct order is black, red and gold.
People of German origin have been referenced or appeared in various historical contexts; other than persons related to World War II, 23rd century Starfleet officer Carl Jaeger was explicitly described as being of German descent in "The Squire of Gothos".
Apart from various locations and the starship USS Berlin named after Berlin, the USS Emden was either named after the German city or one of several German warships. Also, the Danube-class is named after the European river Danube, which originates in Germany.