The trick is to keep them moving. Elephants get a huge charge/attack bonus, so don't squander it by letting them stop and melee with an individual enemy unit. If I am using elephants in the center of my line, instead of simply attacking an enemy unit, I usually double-click BEHIND the enemy unit, so that the the elephants will run through and not get bogged down, thus losing their charge bonus. If I'm using them on the flanks, I will charge them - not at the very nearest enemy unit - but at the next-to-nearest enemy unit in the battle line. Keep doing that all the way down the line, spreading fear as you go.

As already noted, preserve your elephants by 1) only attacking pike or phalanx formations from the rear (even a flanking attack can get them killed); 2) retreating from missile fire, especially fire arrows; and 3) using them in tandem with another unit right at the elephants' feet (skirmishers or cheap melee infantry are great for keeping enemy skirmishers out of range).

Elephants in R:TW are unrealistically powerful, even after the last patch. However, watching elite Roman infantrymen get tossed into the air like matchsticks IS rather fun. R:TR takes a more realistic (though less enjoyable) approach: the elephants are much easier to kill, especially with javelins, and they rout if you breathe on them wrong.