A panel of three Taliban judges passed the order in an area of Badghis province, which is firmly under militant control, The Scotsman reports.
"We gave this decision so that in future no-one should have these illegal affairs. We whipped her in front of all the local people, to show them an example. Then we shot her," Mullah Daoud, a spokesman for the Taliban, was quoted, as saying.
Police said the woman's body was later dumped in an area under Afghan government control.
"She was shot in the head in public while she was still pregnant," deputy police chief in Badghis, Ghulam Mohammad Sayeedi, said.