The cases of A/H1N1influenza were confirmed on Thursday at a hospital in Landstuhl in western Germany. Obama visited the following day to meet wounded soldiers evacuated there from Afghanistan and Iraq.
"The cases involve military patients who were sharing a common area at Landstuhl," a statement from the US military said. "With exception of a patient who arrived from Italy on May 26, none had travelled outside Germany in the past two weeks," it added.
The cases at Landstuhl, the largest US military hospital in Europe, were the first confirmed among US soldiers stationed in European bases. Eighteen US soldiers who tested positive for swine flu were removed from a military base in Kuwait last month.
Last weekend, the Berlin-based Robert Koch Institute reported that the number of swine flu cases in Germany rose to 31 over the holiday weekend.
All of the new infections stem from Germans who recently travelled to the United States, where the A/H1N1virus has spread more quickly than the rest of the world with around 8,000 cases.