Section 165. The agents and servants of the department may enter any building, structure or premises to ascertain whether sources of pollution or danger to the water supply there exist, and whether the rules, regulations and orders aforesaid are obeyed. Their compensation for services rendered in connection with proceedings under section one hundred and sixty-two shall be fixed by the department, and shall in the first instance be paid by the commonwealth; but the whole amount so paid shall, at the end of each year, be justly and equitably apportioned by the commissioner of revenue between such towns or companies as, during said year, have instituted said proceedings, and may be recovered in an action by the state treasurer, with interest from the date of demand.