A high heat is the enemy of a homemade cheese dip. This aids in separating the protein and water in the dairy and will produce those curds. If you see this start to happen, immediately take it off the heat and add a splash of something cool to bring down the temperature such as a few teaspoons of cold milk or beer then whisk like crazy for 10-30 seconds. If this doesn’t work you can try a tablespoon of flour which will help to bind the separated sauce. If all else fails, try a teaspoon of lemon juice of half a freshly squeezed lemon.