The board of supervisors may contract with a city in the county, and the governing body of a city may contract with the county for the performance by health officers or other county employees of any or all enforcement functions within the city related to ordinances of public health and sanitation, and all inspections and other related functions.