For a grain of sand in a 5yo eye should I go to pediatrician, pediatric ophthalmologist or er?

Ophthalmologist. Not easy to get foreign body out of child's eye. You can spend hours in E.R. Go to local ophthalmologist.
Any. Any one of them can help... It depends on how quickly and how bad the symptoms are. If your 5 y/o is experiencing a lot of pain... There might be a corneal abrasion... You are going to have easier access to an er. The er could also more easily provide some sedation/immediate pain relief and would be more able to flush the eye. If it is not causing any problems... Regular peds or wait.
Call for Peds. Your pediatrician may be able to deal with this but if the child is in a lot of pain and the pediatrician is not available, go to the uc or er for a clean out. The sand can potentially scratch the sclera and cornea so getting the sand out is important.
Pediatrician. Call your child's pediatrician for advice. The pediatrician will take care of this problem or refer you to the correct facility if they are not available.
ER or ophthalmologis. An er doctor or any ophthalmologist would be able to remove foreign bodies like that.