The infrared divergences of QCD scattering amplitudes can be derived from an anomalous dimension Gamma, which is a matrix in color space and depends on the momenta and masses of the external partons. It has recently been shown that in cases where there are at least two massive partons involved in the scattering process, starting at two-loop order Gamma receives contributions involving color and momentum correlations between three (and more) partons. The three-parton correlations can be described by two universal functions F_1 and f_2. In this paper these functions are calculated at two-loop order in closed analytic form and their properties are studied in detail. Both functions are found to be suppressed like O(m^4/s^2) in the limit of small parton masses, in accordance with mass factorization theorems proposed in the literature. On the other hand, both functions are O(1) and even diverge logarithmically near the threshold for pair production of two heavy particles. As an application, we calculate the infrared poles in the q qbar --> t tbar and g g --> t tbar scattering amplitudes at two-loop order.