It could be very irritating if your computer restarts itself. You can loose unsaved work and your Hard disk can also be damaged.
Checklist to correct this problem
1. Clean the RAM slot
Remove the RAM from the motherboard and clean the RAM slot with a dry brush. Accumulated dust in the RAM Slot prevents the connection and your PC restarts itself whenever your computer goes low on memory. Cleaning the RAM slot and reinserting the RAM could solve this problem. This is the most common reason for this problem.
2. Faulty Power Supply
If cleaning RAM slot doesn't help then it is possible that your power supply is faulty. Try replacing it with a new one.
3. Over heating
If your CPU fan is not doing its job properly then your processor may get heated up and cause your computer to reload. When buying computer always install a good quality CPU Fan.
4. Virus
If you are one of those unfortunate ones who use Windows Operating System then Virus could be causing your PC to reboot. Update your Anti-Virus software definitions regularly.
5. Motherboard is Faulty
If none of the above solutions work then your Motherboard is not good. Get a new Motherboard :)
In most of the cases the problem get solved by cleaning the RAM slot and in few cases replacing power supply or CPU Fan.