The shooting took place in Gardez, capital of eastern Paktia province, General Mohammad Zahir Azimi, an Afghan Defence Ministry spokesman, said.
The area, near the border with Pakistan, has been a frontline in fighting with the Taliban and other militants.
The attack took place inside a base of the Afghan army in the city.
A US Defence Department official confirmed that all three soldiers were Americans, but that no further details would be released until after their relatives had been notified.
Killings by uniformed Afghans of foreign soldiers rose dramatically last year, eroding confidence between the sides at a crucial turning point in the conflict.
So-called insider attacks killed 62 personnel in 47 incidents last year compared to 35 killed in 21 attacks a year earlier, according to Nato.