A suicide bomber in Afghanistan detonated explosives on Wednesday outside the United States’ main military base of Bagram in an attack that wounded five people, Afghan and NATO officials said.