I have heard several stories, but the two most popular versions are:
1)
In the first part of the epic poem Mahabharata, it is written that the sage Vyāsa asked Ganesha to transcribe the poem as he dictated it to him. Ganesha agreed, but only on the condition that Vyāsa recite the poem uninterrupted, without pausing. The sage, in his turn, posed the condition that Ganesha would not only have to write, but would have to understand everything that he heard before writing it down. In this way, Vyāsa might recuperate a bit from his continuous talking by simply reciting a difficult verse which Ganesha could not understand. The dictation began, but in the rush of writing Ganesha's feather pen broke. He broke off a tusk and used it as a pen so that the transcription could proceed without interruption, permitting him to keep his word.
After some days of the writing the stylus used by Ganesh broke and as he could not stop writing he broke off one of his tusks and started writing with it. This symbolically explains that any amount of sacrifice is not too much to gain knowledge.
2) The story of how Ganesha broke his tusk is recounted in this excerpt from the Upodghata Pada of the Brahmanda Purana. Parashurama, the axe-wielding incarnation of Vishnu, had sucessfully defeated his enemy Kartavirya Arjuna and the kings allied with him, and so he wanted to thank Shiva for giving him the power to fight these enemies. Parashurama went to Mount Kailash to pay his obeisances to Shiva, but Ganesha stopped him, saying his father was sleeping along with his mother, and he didn't want Parashurama intruding on them in case they might be engaged in amorous pursuits. Parashurama was enraged that he was being prevented from seeing Shiva, and so he started fighting Ganesha. Ganesha was winning handily, but then Parashurama threw his axe at Ganesha and Ganesha didn't fight back against it, because the axe was a gift from Shiva:
Perceiving that the axe had been given to him by his father, Ganesha became desirous of meaning it not to go in vain. Hence he received it with his left tooth (tusk). Chopped off by the axe, the tusk fell on the ground, covered with blood like a mountain that fell on the ground when struck by Indra's thunderbolt.