The key (as is almost always the case when you feel aches and pains from piano) is relaxation.
Each of your fingers only needs to be "active" (i.e. not relaxed) at the instant it actually strike a key, because you can move from key to key and hold keys down while relaxing that finger. In fact, if you are not relaxed, you are inhibiting your movement (though this is more relevant to your arm than your individual fingers).
When playing repetitive chord shapes, especially octaves, most students tend to try to "freeze" their hand into the proper shape, then push it down onto the keys in each location on the keyboard where the chord occurs. Thus you are tensing your fingers, palm, and wrist into an awkward, contorted shape while trying to quickly move your forearm laterally. But it's much harder to accomplish this movement quickly, fluidly, and easily when so much of your arm is stuck in a tense state! So you must relax, at every possible instant, rather than trying to maintain the shape.
This means that you need to be able to spread your hand into an octave-shape very quickly, because you must re-form the shape for every octave you play. This sounds difficult, and indeed it's hard to master, but it's mechanically much easier and much better for your arms than "freezing" is.
So you should start by practicing making the octave-shape very quickly. As an exercise, starting with your hand floating above the keyboard and completely relaxed, drop it down onto the keyboard while (at the last possible moment) stretching into the octave.
As you do this exercise, start thinking about what happens when you release the keys. Remember, the octave-shape is tense and uncomfortable, so release it as soon as possible to get your hand back into a relaxed shape. So, first, you can practice relaxing as you release the keys.
...But above, I said that you don't need your fingers to be "active" even when you're holding the keys. So practice dropping your hand into an octave and immediately relaxing as much as you can--and holding this relaxed shape. (This is tricky, but necessary when playing octaves that are too quick for relaxing "between" them.)
Now, the last element of a run of octaves is the movement from octave to octave. This movement must begin the instant you release the keys--or just before, if possible. There are several ways to make this movement. You can try to make a smooth and symmetric arc, but you risk landing on each octave at a slight angle, which can be problematic. Alternatively, you can rise off the first octave in a a shallow slope, moving more laterally than upward, until you are directly above the next octave, at which point you can drop directly down onto it. The optimal motion, in my opinion, is somewhere between the "arc" and the "slope-drop"; you need the smoothness of the arc, the laterals movement efficiency of the slope, and the precision of the drop. So practice both ways, and as you speed up your practice, you should naturally find something that works efficiently and comfortably.