Also, what kind of tasks were required of them during the war from both the host country and the origin country?
edit1: Ok cool, so the staff either left or were detained before being traded.
edit2: What happened to the embassy buildings themselves? Once we were at peace with Germany, did the (new?) ambassadors get to go back to the same buildings? Was anyone afraid that we've planted bugs inside the buildings while they were unoccupied?
German embassies in countries of the Allied Powers (UK, France, US or the USSR) were closed down as soon as Germany declared officially war on these or otherwise. One week before invading Poland the German embassy in London and France advised all German residents in these countries to leave. After the British ultimatum expired on September 3rd, these two embassies were closed down on September 4th. The German ambassador (or Chargé d'Affaires) in London (Dr. Kordt) and in Paris (Johannes Graf von Welczeck) left on the same day. Here is a picture of Dr. Kordt leaving the German embassy on September 4th (bottom right). Graf von Walczek was not permitted to cross into Germany until the French ambassador to Germany arrived safe in Belgium. The Swiss embassy in London and Paris took over some tasks.
Same goes for the German embassy in Moscow. Before Graf von Schulenburg delivered "a memorandum" to Molotov on June 22nd 1941, he destroyed all records and documents in the German embassy. After the meet up he was detained and the embassy staff was arrested. They were later transported to the Turkish border and set free.
The German embassy in the US was closed down right after Pearl Harbor. Staff was set under house arrest. Later they were transferred and detained in various resorts. From the History of the Bureau of Diplomatic Security - Chapter 2 - Diplomatic Detentions during Wartime (PDF warning):
After Pearl Harbor, U.S. officials initially allowed Axis diplomats to stay in their homes and have unrestrained access to the Swiss Legation, but later transferred them to resorts in the Appalachian Mountains until the Department of State could arrange for an exchange of diplomats between the United States and the Axis powers. The Germans had transferred U.S. diplomats to a hotel at Bad Nauheim, yet, reports of Japan’s less than hospitable treatment of U.S. diplomats soon reached the Department. Although “his patience was sorely tried,” Secretary Cordell Hull declared that he would not “be drawn into a contest in which he would have to out stink a skunk;” and “there was a limit below which the United States Government would not stoop” in its treatment of enemy diplomats.
Ambassadors from enemy powers are handed their papers and sent packing as soon as war starts, and WWII was no different in this regard. Such very, very scanty contacts as did take place between Germany and its enemies took place informally between diplomats to neutral countries, e.g. Switzerland for Hitler's "peace" offer in 1940 or Turkey in 1943 (IIRC -- possible 1944) when Himmler tried to sell the lives of Jewish civilians.
edit2: To be pedantic, the people are the "embassy"; the building is the "chancery". But metonymy has long since had its way with the language.
The Vienna Convention on Diplomatic Relations of 1961, article 45, is the current rule, but I believe this codifies older practice. "Sending state" refers to the ones who sent the embassy; "receiving state" is where they went.
The receiving state must respect the premises of the diplomatic mission. The sending state may give custody of its chancery to a third party acceptable to the receiving state. But G. R. Berridge, Embassies in Armed Conflict, p 23 says that the protection in practice is only for the same reasonable short time as for the embassy going home. It's not clear from that whether a third-party protection could continue past that time.
I know, Ireland was neutral in the war, but considering our neighbours, and all, you might be interested in this, for what it's worth.
In Ireland there was a lot of controversy near the end of the war when our Taoiseach, Éamon de Valera, offered his condolences to the German Ambassador over the death of Hitler. This damaged Ireland's relationship with the Allies, and in Churchill's VE day speech he criticized Ireland's neutrality, which lead to this response from De Valera a few days later.
Here in Iceland when Iceland got invaded by the UK the went to the German embassy and arrested the ambassador. :)