In extreme cases, letting a trickle of water run all night will constantly replace the cold water in the pipes with warmer water from the basement or well. Water pipes in exposed locations will need extra added heat. In a small enclosed space like a well pit or pump house, you might consider a small electric heater or heat lamp. Remember to keep fire and electrical safety in mind when selecting and installing heaters or lamps. Adding insulation to the pump house or well pit cover can help conserve the heat that is already present.
Many people use hay or straw bales to insulate over a well pit.
This works, but hay and straw attract rodents and hold moisture. Insulating inside the pit and cover with materials like fiberglass may be a better plan. In open areas like unheated buildings or crawl spaces, you may need to localize the heat directly to the pipes. Heat tapes can be wrapped around the pipe to add heat directly to the pipe. Some heat tapes include built-in thermostats to turn them off in warmer weather.