In the paper, we calculate the fragmentation functions for a quark to fragment into a spin-singlet quarkonium, where the flavor of the initial quark is different from that of the constituent quark in the quarkonium. The ultraviolet divergences in the phase space integral are removed through the operator renormalization under the modified minimal subtraction scheme. The fragmentation function $D_{q to eta_Q}(z,mu_F)$ is expressed as a two-dimensional integral. Numerical results for the fragmentation functions of a light quark or a bottom quark to fragment into the $eta_c$ are presented. As an application of those fragmentation functions, we study the processes $Z to eta_c+qbar{q}g(q=u,d,s)$ and $Z to eta_c+bbar{b}g$ under the fragmentation and the direct nonrelativistic QCD approaches.