I don't think a dowel is going to handle the directional stress. If you look closely, I'm pretty sure the designers have used some sort of lap-joint, possibly reinforced with a metal fastener, and not a continuous piece of stock. You might be able to download the instructions for this bed and see how those parts intersect with other parts.
Or, the factory makes a piece of just over the total length of the leg and headboard using some sort of lap joint, which is then machined down to that profile. Ikea is really good at taking what is essentially scrap and turning it into dimensional pieces and panels. (As someone who has reused an entire Ikea baby room set and turned it into other stuff, it is amazing what you find inside a ripped-down panel!)
But to get two pieces to handle stress as if they were a single piece, you have to get long grain lined up with long grain. Dowels are ok for some sort of joinery, especially those where you are gluing up panels and want to use dowels for positioning, or to stiffen up a long glue line or a mitre. But they are rarely considered a significant part of the overall joint strength.
For your purpose I don't see there being enough glue strength to keep that joint from turning into an unexpected and sudden hinge. And, to be clear, it is the glue that you want to depend on, not a 4-inch piece of crenelated softwood that you hope has expanded properly into the hole surrounding it.
Now, a lap-joint with dowels or splines through the lap would be really strong, assuming your primary glue joint is made up of a fair amount (more than 2 inches, certainly) of long-grain faces.