H is a subset of G containing those elements of G that commute with every element of G.
The sentence does not make any sense if "containing those elements..." refers to G, because by definition G contains all elements of G, not only those with a special property. Therefore, the modifier "containing those elements..." must belong to "a subset of G", namely H.
The boy is the son of the man standing here.
When deciding how to group words, usually we follow this rule: we group together the words which are closest to each other. If that is not possible, we try to group them with words further away.
In the case of this sentence, it is quite difficult to group "the boy" with "standing here". The meaning is: "the man is standing here, not the boy".
If you want to say that the boy was standing, you will say:
The boy standing here is the son of the man.
Now it is clear that the boy is standing, but the sentence is incomplete. Because we have "the man" (one specific), but we have no rule to know which one. This is an additional reason why "standing here" cannot refer to the boy in the original sentence.
Sometimes, grouping can be very ambiguous, and (almost) impossible to disambiguate without knowing the original intention. The example below is very clear:
The girl came to her mother laughing.
We cannot be sure if the girl was laughing, or the mother.