Relay and temperature sensor

An alternative way to handle this is to use two thresholds: turn your heater on when the temp is below the lower one and off when it exceeds the higher. q.v. Hysterisis.