In order to truly "compensate" for it, you either have to cut as many calories as are contained in the item, or you must burn that amount of calories. If "every now and then" means somewhere around or less than once a month, and the rest of the time you eat healthy and maintain a healthy and active lifestyle, I wouldn't worry about compensating for it. If instead it means once or twice a week, you need to compensate for it in some manner.
One of the things you should remember is that you don't need to compensate for it all at once. If you eat an excess of 3500 calories one day, but have a 610 calorie deficit every other day of the week, your weight will be the same at the end of the week as it was in the beginning. Our weight fluctuates constantly within some margin due to this effect and the effect of hydration on the body, and small fluctuations shouldn't be perceived as a bad thing.
If you do want to compensate, you can mix and match cutting or burning in any way you want to to make a full compensation. For example, you could just cut the calories. If you didn't want to cut any calories, you could just work out. If you wanted to though, you could do half the workout and cut half the calories. With the exception of hormonal imbalances, weight gain, maintenance, and loss is all about calories taken in versus calories expended.