"Dear Sir or Madam" versus "To whom it may concern"
I don't think there is a "black and white" rule there. With that out of the way, here's my opinion.
"To whom it may concern" is used where the letter is issued for use by someone without regards to who receives it, whether a person, or an institution etc.
"Dear Sir or Madam" is a more specific address.
Both forms of addressing are used when you don't know their name. Otherwise it's a poor excuse for not being able to make use of technology properly when you do know their name. In which case it would be Dear X Y and Y Z, where the letters are meant to represent full name. It also does away with using titles, as titles are used rarely nowadays, unless it's a personal invitation in a professional circle. "To whom it may concern" are unaddressed offers in the mailbox that end up promptly in the rubbish bin.