  We calculate the two-mass QCD contributions to the massive operator matrix
element $A_{gg,Q}$ at $\mathcal{O} (\alpha_s^3)$ in analytic form in Mellin
$N$- and $z$-space, maintaining the complete dependence on the heavy quark mass
ratio. These terms are important ingredients for the matching relations of the
variable flavor number scheme in the presence of two heavy quark flavors, such
as charm and bottom. In Mellin $N$-space the result is given in the form of
nested harmonic, generalized harmonic, cyclotomic and binomial sums, with
arguments depending on the mass ratio. The Mellin inversion of these quantities
to $z$-space gives rise to generalized iterated integrals with square root
valued letters in the alphabet, depending on the mass ratio as well. Numerical
results are presented.
