  In this paper we study the fragmentation of a parton into a jet containing a
heavy quark. When heavy quarks are involved in a jet, the quark mass can lead
to a numerically significant correction to the jet cross section and its
substructure. With this motivation, we calculated the heavy quark mass effects
to next-to-leading order in $\alpha_s$ on the fragmentation functions to a jet
(FFJs) and the jet fragmentation functions (JFFs), where the former describes
fragmentation of parton into a jet and the latter describes fragmenting
processes inside a jet. The finite size of the heavy quark mass does not change
the ultraviolet behaviors, but it can give significant corrections to the
finite contributions. When we take the zero mass limit, we find that the FFJs
and the JFFs reproduce established results for massless partons. If we define
the heavy quark jet as one that include at least one heavy (anti-)quark, the
tagged heavy quark jet production is sensitive to the heavy quark mass and
produces large logarithms of the mass. Taking advantage of the FFJs and JFFs,
we formulate a factorization theorem for heavy quark jet production in order to
resum these large logarithms systematically. As an application, we study
inclusive $b$-jet production and show phenomenological implications due to
keeping a non-zero quark mass.
