Experiencing this kind of rotation interpolation problems are not common in your case because you are using Quaternion Rotation. But similar problems can be found easily in the shoulder-like joints if you are using Gimbal rotation (any of the Euler XYZ combinations). Anyway, there is a similar approach for both cases.
First, you need to know what kind of rotation is being used. It's simple: under rotation axes you'll find Quaternion or Euler (in this case means Gimbal).
The common solution for both rotation types is adding one (or many) inbetween keyframe to "force" the rotation to go through your desired way (like @sambler told in the comments). If you are working with Quaternions, doing that is a must in big rotation changes.
Why does it happen? In Quaternion, the WXYZ axis are defining a point in a 4-dimensional sphere. For better understanding, we can imaging the same applied to a circle in this image:
So the rotation is actually a point traveling through a circle but not only through the edge. In your case, I think that your rotation was more than 180 degrees, so the interpolation went by "the other way" of the circle.
Note that the spacing of the rotation is not linear, so it's always recommended inserting inbetween keyframes specially in big rotations.
In Gimbal that's caused because of the gimbal lock. Gimbal axes are parented between themselves. So if you're working on a Euler XYZ setup, X is the child of Y, which is the child of Z. If you rotate 90 degrees the Y axis, then the X axis will align with the Z resulting that two axes are doing the same rotation and you have lost a rotation axis actually.
So there's another solution if you are working with Gimbal: Euler Filter. Euler Filter is located in the F-Curve Window in the Key Menu:
There is plenty of material in the Internet about Gimbal lock. If you want to know more about Quaternions or Gimbal in Blender, are pretty well covered in Nathan Vegdahl's Humane Rigging DVD (you can check Quaternions video here). Actually the two circle images are from that video (under a CC Licence).