My DH had similar, but less serious, tendencies until I beat them out of him (joking, in case anybody comes on to tell me that I’m an abuser).
He works from home (so is tempted to pick at stuff) but also attempts to be healthy. So when it’s his shopping week - we alternate - he won’t buy chocolate, crisps, ice cream etc. However, he loves having that stuff around, and he’ll often say, “I really fancy a treat, what have we got?”.
He just doesn’t like buying sweet stuff for himself because then he can pretend that it’s somebody else’s fault that he fell off the wagon!
I can have nice things in the house without scoffing them immediately, so when it’s my shopping week I’ll buy all the good stuff. However, I have learned to warn my DH off things that clearly aren’t for him. For example, I bought some kids’ kinder bars for my niece and nephew, hid them in a tin, and he found them and ate them despite them (1) clearly being intended for the children and (2) having been kept out of sight deliberately. Reason: couldn’t find any other nice stuff. Yes, because he’d told me not to buy chocolate that week because he was being healthy!
Another time my dad bought me a box of chocs, not expensive but unusual. I got home to find that DH had broken into them. In fairness he was apologetic and said that he’d get me some more, but the box was a special edition and it had sold out, so I had to have something not quite so nice and not what my dad had picked out for me. DH felt pretty bad about that.
I solved it by agreeing with him that anything kept in particular, named places was not to be tampered with and that if he got a sweet craving during the day he could walk five minutes to the bloody shop and buy something himself! It worked.
Mind you, then I had to move on to explaining that scoffing everything in a bag of sweets apart from one solitary item, because then he can say that he didn’t finish them, isn’t on either.