Provincial spokesman Dost Muhammad Nayab said the attack took place on Monday morning and that four other soldiers were wounded in the attack.
Thirteen Taliban were also killed in the battle, which took place on the outskirts of Tirin Kot, the provincial capital.
A provincial security official gave a different toll, saying 10 soldiers were killed in the attack.
The discrepancy in the casualty toll could not immediately be resolved.
The Taliban did not comment on the attack. The insurgents frequently attack Afghan security forces across the country.