This is the most frustrating part of sewing with a sewing machine but is easily rectified when you know how!
When you finish a row of stitching, ensure that the needle stop is in the up position if your machine has the facility, this ensures the machine has completed the whole stitch and ready to begin a new one. The check-lever needs to be at the highest point too. If you have a machine that requires you to raise the needle by turning the handwheel, make sure you turn it until the check lever is also at the highest point.
Taa Daa!
No more unthreaded needles!

Alternatively you can remember to keep hold of the threads for the first few stitches every seam.