Onboard the Apollo capsule, the astronauts probably weren’t allowed to smoke because of the risk. Apollo 1 blew up because of a small spark in a pure oxygen environment. Even though NASA changed the air in the Apollo spacecraft, there was still risk. Were any of the Apollo astronauts smokers and if so, were there any incidents where they were craving a cigarette, but couldn’t get one?
In the early years of the Space program, smoking everywhere was considered normal. But NASA was ahead of its time. After members of the "Original Seven" were seen smoking on TV, NASA was concerned about the squeaky-clean image the astronauts and urged the astronauts to quit smoking.
Wally Schirra quit before his Apollo 7 flight.
So in the sources I can find, the smoking was "only" a public image issue. All the astronauts seem to have had enough common sense not to smoke where it would be dangerous (ignoring the fact that smoking in itself is dangerous for the smokers and the people around them).
Some astronauts did smoke, see the embedded Why you can’t talk about the Moon landing without mentioning cigarettes video in. Some of the original Mercury astronauts can be seen smoking at the press conference announcing the astronauts. Also see, When NASA Told Its Astronauts to Quit Smoking