When I put coconut milk in coffee, curds and lumps form, which does not look good in coffee. When I heat coconut milk, curds are still form. What can I do to avoid this?
Regular milk is an emulsion - a liquid [fat] suspended in another liquid [water], in its simplest terms.
Coconut milk is a suspension - a solid suspended in a liquid.
Mixing an emulsion into another similar liquid base tends to remain emulsified.
Mixing a suspension into another liquid, there is a distinct possibility that the two will re-separate, due to the heat-shock, & form clumps.
Perhaps if you pre-heated the coconut milk, it may tend to mitigate that, though your tests would seem to say otherwise.
I'd hesitate to say add a thickener first, such as cornflower, & preheat - this would bind it, but I'm not sure the result would be pleasant.