During the Cold War*
And if it is wholly a fabrication, where did the story originate from.
It's not a myth, and it extends even to the highest levels of the German military and governmental establishment. Albert Speer, Hitler's Minister of Armaments, makes it very clear in his book Inside the Third Reich that avoiding capture by the Russians was foremost on the minds of the Third Reich leadership at the time the Nazi government was falling apart.
Some of this is ideological. But a not-inconsiderable part of it was because of the way the war was fought on the Eastern Front. Nazi racial ideology considered Slavs and Jews to be inferior races, and so they fought the war in the East with a view to extermination or enslavement of the natives. In the West, that wasn't the case. Because of that, the Germans much preferred to surrender to the Western Allies, knowing that the French, British and Americans would treat them much more humanely. Have a look at Evans's The Third Reich at War, if you want more details.
The German 12. Armee fought its way to the (by the Soviets) encircled 9. Armee just southeast of Berlin, joined up with it and together with a large number of civilians on the 1st of May. The two armies then fought their way through the Soviet lines and crossed the Elbe river in order to be able to surrender to the Americans.
The US troops even had to withdraw from their positions at the river banks close to the Tangermünde birgde becase Soviet shells intended for the desperately fleeing Germans were frequently landing among American troops. On the 7th of May 1945, the last survivors had found refuge behiond the lines of the US 9th Army on the western side of the Elbe.
As a follow up question, how much of this was due to the Nazis ideologies about the Soviets/Communists/Slavs being beneath them compared to the fear of the conditions under which they would be held as PoWs?
A few posts have mentioned the surrender of Von Braun and other German scientists, and I'd like to add a little bit more on that aspect. First, an excellent book on this topic is Red Moon Rising, by Matthew Brzezinski, which goes into the history behind the Soviet and US rocket programs immediately following the war.
The rocket scientists that Brzezinski mentions (von Braun, Hirschler, etc) were literally smuggled out of Germany under the noses of the Russians, under the codename Operation Paperclip. This initiative, led by the Office of Strategic Services (OSS, a precursor to the CIA), focused on finding and "convincing" former Nazi scientist to continue their rocket research for the Allied (mainly U.S.) cause. I use the word "convincing" rather loosely; the Nazi scientist were well aware that the next great conflict, if one should arise, would be between the USSR and the West. The scientists were also well aware of the sentiments and the overall hostility of the Russians towards all Germans, especially those involved in the Nazi party. Although the topic of von Braun and his fellow scientist's "Nazi past" has been widely debated, the fact remains that in the eyes of the Russians, they were all equally guilty of being ardent Nazis.
Realizing this, von Braun and his team of scientists decided to surrender en masse to the Americans. Although they knew that the Americans represented their best chance at continuing their scientific pursuits (not to mention, they had less of a chance of being shot on site by American soldiers than they did if they were to surrender to the Soviets,) the scientists still had reservations for their safety. As was happening all over Germany, hundreds of thousands of German civilians and soldiers were surrendering to the Americans, British, and French, only to be turned away or handed over to the Soviets, which meant almost certain death. As an insurance policy, von Braun had the foresight to hide copies of V-2 missile blueprints near an abandoned mine shaft in the recesses of Mittelwerk, which he would use to bargain for his group's safety if the need were to arise.
After his surrender to American forces on May 2nd, 1945, von Braun gave his American captors the location of various factories (primarily Mittelwerk and Nordhausen) which still contained V-2 missiles and their components. These factories also contained the necessary machinery to create these V-2 parts, which the Americans dismantled and shipped back home. One of the most important discoveries that the Americans came across was the highly valued gyroscopic navigation computer that was revolutionary in the V-2, which was later implemented in the U.S. Redstone and Jupiter programs.
Von Braun had played his cards correctly. Not only did he give the Americans the location of Mittelwerk, thereby giving them access to a literal V-2 assembly line complete with parts and machines, but he also was able to continue his work by volunteering to help the Americans with their fledgling rocket program. The Soviets, on the other hand, had to resort to more "creative" methods of nabbing Nazi scientists. These methods included: kidnapping, holding families for ransom, and "shanghaiing" drunk scientist in the middle of the night. Also, the quality of the missile parts and scientists that the Soviets were able to garner was far below that of the American's haul. What the Soviets got were second rate machines (and their operators,) middle-management type rocket engineers (those familiar with maybe one aspect of the project, but not with the "big picture") and so on.
One of my relatives actually had to do this. He was a captain in the wehrmacht and he led his men away from the russians towards the americans because he heard how brutal the russians would be towards prisoners.