Front and Rear speed shifters aligment guide
It sounds like your derailer(s), or derailleurs if you prefer, are out of adjustment. Derailers work by guiding the chain from side-to-side to shift gears. They have limit screws that are supposed to stop the movement before the chain comes off, but if the limit screws are misadjusted it will be possible to shift beyond the limits of the chainrings in the front and/or the cogs in the back.

From what you've said it sounds like you can get things back on track (so to speak) by shifting both derailers towards the middle of their range, then put the chain back on – any cog and ring that seem close – and pedal (have somebody hold the rear wheel up when you do this). The chain should settle onto the proper gear. You may hear some noise from the chain as it runs against on or both of the derailers (and may bounce around between gears if you get it just wrong). You should be able to make the front and maybe the rear quite down by making small adjustments. In any case, as long as you are towards the middle, the chain should stay on.

If you find the chain coming off as you shift towards the extremes you'll need to adjust the derailers. Start with the limit screws. Parks has a articles on adjusting the front and rear as does Sheldon Brown. One thing to keep in mind is that rear detailers are also sensitive to the alignment of its hanger.