  The transverse momentum-dependent fragmentation functions (TMD FFs) of heavy
(bottom and charm) quarks, which we recently introduced, are universal building
blocks that enter predictions for a large number of observables involving
final-state heavy quarks or hadrons. They enable the extension of fixed-order
subtraction schemes to quasi-collinear limits, and are of particular interest
in their own right as probes of the nonperturbative dynamics of hadronization.
In this paper we calculate all TMD FFs involving heavy quarks and the
associated TMD matrix element in heavy-quark effective theory (HQET) to
next-to-leading order in the strong interaction. Our results confirm the
renormalization properties, large-mass, and small-mass consistency relations
predicted in our earlier work. We also derive and confirm a prediction for the
large-$z$ behavior of the heavy-quark TMD FF by extending, for the first time,
the formalism of joint resummation to capture quark mass effects in heavy-quark
fragmentation. Our final results in position space agree with those of a recent
calculation by another group that used a highly orthogonal organization of
singularities in the intermediate momentum-space steps, providing a strong
independent cross check. As an immediate application, we present the complete
quark mass dependence of the energy-energy correlator (EEC) in the back-to-back
limit at $\mathcal{O}(\alpha_s)$.
