I hope you see the intended meaning of both of those sentences.(I dont actually know if both of these are valid, I just made them up) I know gerunds assume the role of a noun but would you really understand the first sentence as "The hearing of this makes me sad" or are they identical? This question is bound to be perceived as unclear but since you would very rarely use a noun ( (the) hearing ) in my native language this is especially confusing to me. Is one of the two sentences more likely to be used?
Both sentences are correct — they simply use different grammatical forms as subjects:
Like you said, the first sentence uses the gerund "hearing" as its subject. Turning it into "The hearing of" is basically the same thing, but it can make it confusing as to whether the hearing belongs to "this" (a possessive use of "of," which changes the sentence's meaning) or whether its an objective use of "of" — identical in meaning to "Hearing this..."
The second sentence uses a subjective infinitive, which is identical in meaning to the gerund example but (as FumbleFingers suggested) can be more limited in use.
As others have already said, they're both correct and there's very little difference between them. However, most people would say "It makes me sad to hear this", with a dummy pronoun in front, rather than "To hear this makes me sad", which sounds more formal. "Hearing this makes me sad" is also perfectly acceptable and not overly formal.