It's OK to pet a ESA; in fact, being petted is one of its primary jobs.
It's always a good policy, however, to ask before attempting to pet any animal.
Service dogs are allowed to go anywhere their handler goes, are not to be separated from its human and do not have to wear a vest.