Codes commonly require PEX to be at least 18 in. away from the water heater and 6 in. away from single-wall flues on gas water heaters.