How do I stop banelings from wiping out my marines?

There are a couple of things you can do to avoid an untimely acid-drenched loss.

Early Detection

The earlier you scout that Baneling nest, the sooner you can begin preparing to counter banelings. If you're worried about baneling landmines, get a Raven as soon as possible, as it is economically unfeasible to continuously use scanner sweep to preface your advance (though in a pinch, they work fine).

Research and Upgrades

The Marine Combat Shield and Infantry armor help minorly against baneling assaults, but the real research to aim for is Stimpacks. Stimmed marines move at 3.37 and change, which is faster than even speed-upgraded banelings (at 2.9531 (+0.4531 with creep)). Unupgraded, Baneling's speed of 2.5 will overtake the 2.25 speed Marines. Stimmed Marines can not only escape alive, but can kite the zerg, taking potshots at the encroaching banelings if you've got decent micro. See this question for more on that.

Army Composition

Stick some marauders in your army! Not only do their concussive shells slow down the baneling advance, but they have both more health (125 compared to 45(55)) and lack the "light" keyword that gives banelings bonus damage against marines.

You can almost never have too many medivacs -- if you're trapped or otherwise able to escape, you may be able to load your marines into the dropships to save a large portion of your forces.

Micro

Perhaps the most important thing to consider is how well you control your marines, and how well your opponent is controlling their banelings. Banelings are extremely cost effective units if they get to use most of their splash damage, so your goal is to minimize the number of units hit by any one baneling. If you watch professionals play the game, you can sometimes see things such as a single marine peeling off from the ball to suicide against 2-3 banelings -- the fewer units over which you can spread the baneling damage, the better your odds of coming out of the skirmish with your army still intact.