The first thing you must find out is if it backfires through the exhaust or the intake or carburetor side of the engine. In a lot of cases it will be on the intake side of the engine. When it backfires, it is sending out raw fuel out the carburetor and the ignition is igniting it and you may see flames come through the air filter or it blows off the air filter box completely. When it blows the fuel out, the combustion chamber has no fuel left in or very little and the engine dies. The same thing can happen in the exhaust.
So obviously we have a timing problem or a valve problem. A set of tests must be done to determine what the problem is. The first test is a leak down test. This will tell you if your valves are leaking and which one is the culprit. It could be both of them causing the problem.
Checking the engines timing is more difficult and requires that the engine be taken apart to see if the timing gear cam or chain has jumped a tooth. But before you go ripping things apart, check the flywheel key to make sure that it is not partially sheered. One some models you have to remove the flywheel to check it, but on most you remove the nut holding it in place and you will see it.
These tests are often out of reach for many home owners because they do not have the test equipment. Check our Locations page for a shop near you for help.