1. He dislikes going to school.

2. He dislikes to go to school.
(Are both grammatical? Which one is commonly used?)

2 answers

#1 is good. #2 is not. "Dislkes" is a transitive verb so needs a direct object. "Going" is a gerund (used as a noun) so is the direct object "To go" is a verb, so cannot be the direct object of another verb.

going" is a gerund (used as a noun) so is the direct object. "go" as in "to go" is a verb, not a noun, so cannot be the direct object of another verb.
the first one is commonly used, when you say the second one out loud it doesn't really make sense.