If you are losing the spark to the spark plug you will need to check the coil and the igniter.
If it starts cold, runs until it warms, then quits it is likely the igniter and/or coil.
If you are using the term losing spark figuratively and it just quits but still has a spark to the plug, then it is likely a fuel supply issue such as a dirty main jet or clogged screen on the fuel valve.
These are also a bit picky about valve adjustment being correct, same for the timing. If it has been flogged a bit, then I would check the timing chain adjustment and be sure the timing marks are aligned when I adjusted the valves.