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?
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.