It’s believed that when you work out on an empty stomach, your body burns the excess fat to produce energy. It happens because there are no carbohydrates to burn in the body.
But working out with an empty stomach could cause many side effects, such as burning protein, losing energy resources, low blood sugar, etc.
So it’s better to exercise 1-2 hours before your last meal before fasting. For example, if you start fasting around 8 PM, do your workout around 5-6 PM, eat soon after and finish your meal before 8 PM.