The Taliban has claimed responsibility for the attack.
Attacks on security forces have increased as Afghans gear up for a presidential election scheduled for August 20.
However, the attacks have come mainly in the south where Taliban fighters have their strongest presence.
James Bays, Al Jazeera's correspondent in Kabul, the Afghan capital, said: "We have certainly seen a lot of violence during the election campaign already and we still have just less than three weeks to go until polling day.
“I think what's significant is that this [attack took place in] Herat, a relatively peaceful city, a relatively prosperous city here in Afghanistan near the Iranian border ... but attacks there have been on the increase," he said.