This issue is more common in novice runners, so it may disappear as you become more fit. Try to avoid eating for at least two hours before you exercise -- the presence of food in the stomach will make things worse or contribute to the problem. It helps to avoid high-fiber foods (fruit, vegetables, legumes, whole grains) and coffee/tea before working out, stay hydrated, and consume a sports drink (like Gatorade) during long runs to maintain electrolyte levels. Before running, try to stick to foods that are more binding, such as white rice or bananas.
Consider limiting your intake of dairy products. The protein found in dairy products takes a long time to digest. If you've ever had problems with lactose intolerance or you're susceptible to diarrhea, avoid dairy altogether for the two days leading up to a long run or race.
Be aware of your bowel habits and try to time your workouts for after such movement times. If you're running in the morning, give yourself plenty of time to take care of business before you start running.
You should also consider a medical check-up for irritable bowel syndrome and be open in discussing your problem with your health care provider. If the problem persists, even after you become a more experienced runner, talk to your doctor about possible causes.
It's comforting to know where you can make a pit stop during your runs. Try to plan your long runs along routes where you know bathrooms are accessible. It also doesn't hurt to carry some spare toilet paper in your pocket or running belt in case of emergency. And if you need to make a pit stop on race day, don't worry. You'll find plenty of porta-johns at the start and along the race course. They'll be marked on the course map, and you'll be able to easily see (and maybe smell!) them along the course. In most cases, you can find them near the water stops.
If you've tried many different strategies with no luck, you may want to try an over-the-counter anti-diarrhea product such as Imodium. It is safe to use for exercise-induced diarrhea, but you shouldn't make a habit of using it. Save it for races or special events where you know there won't be any port-a-johns available.