There's some documentation here: https://docs.px4.io/main/en/flight_modes/offboard#ros-2-offboard-control. I would review that to make sure you are following the correct procedures.
That'a a calibration parameter that is set automatically by the mag calibration procedure. Normally it should properly detect the orientation / rotation and set it. I'm not sure why that wasn't happening for you when you calibrated the mag.