We study the lepto- and hadroproduction of a heavy-quark pair in the ITMD factorization framework for dilute-dense collisions. Due to the presence of a nonzero quark mass and/or nonzero photon virtuality, new contributions appear compared to the cases of photo- and hadroproduction of dijets, for which the ITMD framework was originally derived. These extra terms are sensitive to gluons that are not fully linearly polarized. At small x, those gluons emerge only when all saturation effects are carefully taken into account. Therefore, the resulting contributions are absent in linear small-x frameworks, where gluons are fully linearly polarized. We show, however, that even for large gluon transverse momentum, these contributions are not always negligible, due to the behavior of the off-shell hard factors.