We present a closed formula for all Bern-Carrasco-Johansson (BCJ) numerators describing Ddimensional tree-level scattering amplitudes in a heavy-mass effective field theory with two massive particles and an arbitrary number of gluons. The corresponding gravitational amplitudes obtained via the double copy directly enter the computation of black-hole scattering and gravitational-wave emission. Our construction is based on finding a kinematic algebra for the numerators, which we relate to a quasi-shuffle Hopf algebra. The BCJ numerators thus obtained have a compact form and intriguing features: gauge invariance is manifest, locality is respected for massless exchange, and they contain poles corresponding to massive exchange. Counting the number of terms in a BCJ numerator for n−2 gluons gives the Fubini numbers Fn−3, reflecting the underlying quasi-shuffle Hopf algebra structure. Finally, by considering an appropriate factorisation limit, the massive particles decouple, and we thus obtain a kinematic algebra and all tree-level BCJ numerators for D-dimensional pure Yang-Mills theory.