Yeah for this reason a mix of cardio and weight training is essential. Or at least time your runs. When I eat poorly I can still do my usual 5K with no trouble, and I often don’t even feel any slower, but the timer doesn’t lie…
I noticed that when Im not working out I have poor food choices and when I eat like crap I avoid training or it’s a lot more unpleasant than it should be.
Also training results in physiological changes that help losing fat and be generally healthy. Just make sure you’re not losing too much muscle size with the fat.
To some extent you always need to manage your caloric intake of course - but if you exercise regularly, the occasional indulgence isn’t a big deal.