could be a couple things. for a 2stroke if you're running rich or if you're running a sh*tty pipe that doesn't suck the charge in hard enough, you could be sending unburned fuel into the expansion chamber. once the engine gets warmed up, the unburned charge will combust.
on a 4stroke, you can get light backfiring from having a lean jetting. this is most common in the idle circuit, not so much in the main circuit or needle position. backfiring on a 4stroke is most commonly experienced on hard deceleration w/ engine braking. this is because the pilot circuit is too lean and is creating excessive heat in the combustion chamber, which is discharged through the valve.
of course a rich mix can also cause backfiring in a 4stroke the same way as a 2stroke.
i think. someone correct me if i'm wrong here.