Acid-Temperature coagulation of milk
Coagulation of milk is a result of casein micelles clumping together. This is favoured by higher temperatures and also by favour a pH of around 4.6 as this is the isoelectric point. At this isoelectric point, the amino acids within the casein micelle are electrically neutral. This means there is less electrostatic repulsion between the casein micelles, facilitating coagulation Furthermore, the addition of acid means that the kappa casein, i.e. hairs on the outside of the casein molecule which stabilise it, become protonated. This protonisation causes them to destabilise, making it easier for the micelle to fall apart and clump together with other micelles that have fallen apart. Relatively High temperatures also increase reaction rates, which overall speeds up the aforementioned processes as well. 

Even if the coffee does not reduce the pH by much, any change in pH which leads to the pH being closer to the isoelectric point (4.6) of the casein micelle will increase the rate of the coagulation process.

Using old milk also increases coagulation, as milk naturally coagulates due to rennet, an enzyme, cleaving the kappa-casein, causing the casein molecules to destabilise.

To avoid coagulation during heating, perhaps try heating the milk gently. The ideal temperature at which milk coagulates is about 43ºC, so perhaps staying below that could work. This source also provides tips on how to avoid coagulation while heating milkAlternatively, you have yourself some cheese to enjoy :)