Via Snopes:
Both U.S. astronauts and Soviet cosmonauts initially used pencils on space flights, but those writing instruments were not ideal: pencil tips can flake and break off, and having such objects floating around space capsules in near-zero gravity posed a potential harm to astronauts and equipment. (As well, after the fatal Apollo 1 fire in 1967, NASA was anxious to avoid having astronauts carry flammable objects such as pencils onboard with them.)