On this one, you need to work in the x-y plane: The ## B ## that generates the torque in the direction of interest lies in the x-y plane. (Calling north as the positive x-axis and and west as the positive y-axis, the ## B ## of interest is ## B_x ##). The torque is proportional to ## \sin{\theta} ##, and the work is ##\int \tau_o \sin{\theta} \, d \theta ##, where ## \tau_o ## is the value for ## \theta=90 ## degrees. (Note: The axis of rotation is the z-axis. The ## B_z ## that you computed will not cause any torque in the z-direction=that is why your calculation doesn't work).
Edit: Note: The problem can also be worked as a rotation about the y-axis, but you will find that the ## B_z ## has a null effect, with the y component of the torque being in opposite directions as the dipole moment passes through the z-axis. Once again it is ##B_x ## that determines how much work is needed.