In the paper, we calculate the fragmentation functions for g → B c and g → B * c . The ultraviolet divergences in the calculation are removed through the renormalization of the operator definition of the fragmentation functions under the modified minimal subtraction scheme. We then obtain the fragmentation functions D g→Bc (z, µ F ) and D g→B * c (z, µ F ), which are presented as figures and fitting functions. The obtained fragmentation functions are complementary to the previous works on the next-to-leading order fragmentation functions for b → B c (B * c ) and c → B c (B * c ).