Soft radiation in heavy-particle pair production: All-order colour structure and two-loop anomalous dimension