It's a tricky question. There are the dates of surrender. The final surrender of the Germans occurred on May 8, 1945. The Japanese annouced their surrender and a cease-fire on August 15, 1945 (their time, August 14, 1945 US Time). The formal paperwork was signed on September 2, 1945 (Japan time, Sept 1, 1945 US time).
That's the surrender. However, by tradition, wars don't formally end until a treaty of some kind is signed.
This was tough because the Soviets were very stubborn on the final peace treaty.
So, from one point of view, the War in Europe didn't end until 5 May 1955. This is when the French, British, and US ended all formal occupation of their areas, and merged them into the Federal Republic of Germany or "West Germany". They had actually done so earlier 0n 23 May 1949, but it took a while to get all the final details settled.
The peace treaty was signed with Japan on September 8, 1951. So, this ends the war in the Pacific. The US occupation of Japan ended completely April 28, 1952.
Unlike the German situation, the Japanese peace treaty was signed by everyone officially at war with Japan except Burma, India and Yugoslavia. They just didn't want to attend the conference since it seemed like just a formality. Italy was technically at war with Japan since 1945, but this was done after they switched sides in the war. It seemed bad taste to invite them.
Germany was more of a mess because the Soviet Union and the other Allies were fighting about the future of Germany. From the traditional point of view, the war never ended in Europe because no peace treaty was ever signed. They just stopped fighting.