Custard curdles when the egg proteins cook too quickly and clump together. If you see tiny lumps, you've caught it just in time.
The Blender Save
Immediately remove the pot from the heat. Pour the custard into a blender and pulse for 15-30 seconds. The high-speed blades will break up the protein clumps and emulsify the mixture back into smoothness.
The Sieve Method
If you don't have a blender, pour the custard through a fine-mesh sieve into a cold bowl. This won't fix the emulsion, but it will remove the 'scrambled' bits of egg.