Peter is correct to direct you to your local plumbing authority for the installation requirements. However, as far as I know, the codes do not specify any minimum distances of the water heater body from walls. Modern water heater tanks have insulated bodies that may be quite close to and even in contact with surrounding walls. So far as I knoew, the building codes are silent about this. However, the codes do specify such things as the construction of and the minimum clearances of the water heater vent pipes from combustible materials, the minimum elevation of the water heater firebox (18″) above a garage floor, the types of inlet valves (full-bore), and the location of unions (within 12″ of the heater), etc…
NtP