Note that by the time Macbeth orders the murder of Macduff's family, Macduff has already fled to England, seeking to align himself with Malcolm, the rightful heir to the throne. This is the reason why Macbeth orders the murder of Macduff's family to begin with.
Macduff will learn about his family's murder in act 4, scene 3 (the same scene in which he swears loyalty to Malcolm). Already, by this point in the play, he perceives Macbeth to be a tyrant and wishes to rescue Scotland from his unjust rule. This is why he originally swears his loyalty to Malcolm: he already sees Macbeth as his enemy and someone that must be opposed for the good of Scotland.
But with Ross's revelations about the murder of his family, this conviction is transformed to some degree, as Macduff's desire to free Scotland from a tyrant is now joined by a need to achieve vengeance for his slaughtered family. But note that his initial response is also one of mourning, joined with a sense of disbelief, as he is shown struggling to come to grips with the cruel turn of events that has occurred. We see him grieving in this scene, even as Malcolm insists that Macduff turn this grief into anger. This is precisely what Macduff does, as he vows vengeance against Macbeth.