There are many stories and can not be said which one is correct, my version -
Ganesha used one of his tusk as a pencil to write Mahabharata, Ved Vyas requested Ganesha to help him to write Mahabharata and he agreed ultimately he was the symbol of knowledge. Since no good pen was available so Ganesha broke one of his tooth and used it as pencil.