Heim served during World War I and the post-war German army. He reached the rank of Oberst in August 1939, just before the start of the Second World War. On September 3, 1940, Heim was appointed Chief of Staff to Feld Marshal Walther von Reichenau while the Sixth Army was concentrated on the Cotentin Peninsula awaiting the Invasion of Britain. He was subsequently prominent in the planning of the German invasion of the Soviet Union. On 1 July 1942, he was commander of the 14th Panzer Division taking part in the Second Battle of Kharkov and at the battle of Rostov. On November 1, 1942, he was given command of XLVIII Panzer Corps which was then part of the German 6th Army, at the Battle of Stalingrad. Heim's XXXXVIIIth Panzer Corps was placed behind the Romanian 3rd Armyat the beginning of the Soviet Operation Uranus "to check the enemy attack" along Paulus's left flank. Heim's 48th Panzer Corps, consisting of "two badly weakened divisions", was surrounded and barely broke out to the west. "Hitler made him a scapegoat and relieved him of his position...despite the obvious lack of fighting experience, equipment and strength in Heim's Rumanian and German divisions.." After this, in January 1943, Heim was, at Hitler's order, dismissed from the Army, arrested and placed in solitary confinement at Moabit, finally being released in April 1943, when he was transferred to a military hospital at Ulm. In a post-war interview, Heim asserted that the only documentation for his arrest was Hitler's order – no indictment, sentence or explanation. He learned, unofficially, that Hitler had been unwilling to cast blame on the Romanians for the poor quality of their troops so a German scapegoat was needed. German army and army group commanders were too valuable, so the "... only person left was the corps commander, and that was me." Heim was informed in May 1943 that his dismissal from the German army had been revoked, and that he had been classified as retired. In August 1944, Heim returned to command German forces at the "fortress" of Boulogne, a "defend to the last" assignment. He was instructed to prepare significant defences but he arrived to find that nothing had been prepared and there were no suitable specialists to do the work. The ill-prepared and ill-suited garrison endured heavy bombardment and full-scale assaults when the 3rd Canadian Infantry Division launched Operation Wellhit. Heim surrendered to the Canadians on 23 September 1944.
Post-war
Heim was sent to a series of POW camps in Britain and subsequently repatriated to Germany on 12 May 1948. He died at Ulm on 14 November 1977.
"We must uphold the principle of only having carried out orders We must stick to that principle if we are to create a more or less effective defence" - spoken in secret while prisoner to his fellow inmates regarding German atrocities in World War II