Dobby apparated to Hogwarts to put a charm on the Quidditch Bludger to follow Harry and try to hit him. The question is, though, how did Dobby apparate to Hogwarts if he had never been to Hogwarts before? The exact location is a secret and it is unplottable. You need to know the location of a place to apparate to it, so how did Dobby get to Hogwarts?
3do we know Dobby had never been to Hogwarts? Also - elf magic seems to be more powerful and able to get around regular wizarding rules– NKCampbellOct 16, 2019 at 22:13
16Malfoy Sr. is a school governor and regularly visits the school. Dobby travels with Malfoy Sr.– ValorumOct 16, 2019 at 22:13
Dobby may have traveled with Malfoy Sr. since he is a school governor, and we all know Dobby usually tags along to wherever Malfoy Sr. goes.
1and we all know Dobby usually tags along to wherever Malfoy Sr. goes. - how do we know that? Oct 17, 2019 at 0:24
2in the chamber of secrets final chapter we see Dobby preparing to go with Malfoy Sr. Oct 17, 2019 at 0:39
2he wasn't preparing to go he was forced to apparate there in a hurry: scifi.stackexchange.com/a/79323/13716 Oct 17, 2019 at 0:50
We don't know whether Dobby routinely visits Hogwarts with Malfoy Sr., but we know that he can follow him there, even without explicit orders, because he did so at the end of Chamber of Secrets.
It is reasonably likely that Malfoy Sr. called upon Dobby while at Hogwarts at some point in the past, but even if he didn't, Dobby could easily have followed him there on one pretext or another sometime between his visit to Harry's home and the first Quidditch game of the season. He'd have had to punish himself, but that wouldn't have stopped him.