I am looking for a bracket that will attach a 2x2 support to the underside of a bed. The support needs to be attached to the headboard and footboard with this bracket at each end. What is this called and where can I find one?
The closest you're going to get is joist hanger brackets.
There are some short versions that may be adaptable.
All kidding aside, there are stainless steel hanger brackets for 2x2 made for Macaw and Parrot cages similar to your item shown. Probably a little expensive.
The item shown is an OEM bracket made specifically for the furniture manufacturer.
That support bracket looks like it was manufactured specifically for that purpose. I very much doubt you will find an equivalent bracket for a 2 x 2 layig on a hardware store shelf. What you could do is look in the "joist hanger/framing tie/framing bracket" section of your local supply store and, with a bit of ingenuity, adapt or alter a bracket to serve your needs.
Google "bed rail bracket", and you'll see a bunch of possibilities. Some need to be mortised; others just screw on.
Maybe try Short Run Pro? They have custom brackets that may work for what you're looking for. You can also submit a drawing design to them as well.