This is economic warfare, not a threat to health
"Junk" food is not by itself a cause of bad health
Every week / month / year / decade there is a new type of food that is described as The Bad Food™. And every time a bunch of people will make a career or just a quick buck out to prophesying against this latest "scourge".
One of the most famous of these is the film Super Size Me.
Synopsis: Guy goes on a diet where he only eats at McDonalds. He gains weight, his body goes haywire, his blood values are shot to hell. So he concludes this is all McDonalds's fault and it is the food that is to blame.
No, not so...
When looking closer at what the film-maker did, it turns out that he was deliberately over-eating, consuming twice the calories someone of his gender, weight and daily physical activity should be eating. He also went from a physically active life to becoming a couch potato.
Essentially he ran head first into a wall and then blamed the wall for his injuries.
Other people reacted to this and also went on McDonalds-Only diets. But they did not over-eat, and instead they stayed at the required caloric intake and maintained their regimen of physical activities. These people instead lost weight, and their blood values improved.
The conclusion is that if you over-eat, you will end up with bad health, no matter what it is that you eat. The so called "junk" food is not nearly as much junk as it is made out to be. The real snake in the garden is ourselves, eating too much while not having physically active lives.
So can this work as a form of "warfare"? Well... no, because while you might induce a cost in the form of increased medical cost due to over-eating, you have almost abolished the food cost for this country. This means lots of money over to do fun stuff with, like for instance be collected as taxes to boost the health services. And of course the soldiery will not be afflicted by this because they are on a fixed diet anyway and are keeping up an exercise regimen to keep them fit.
So the people will not be very much afflicted by this.
...what you are doing is economic warfare. You just pulled the rug out from all the commodity producers that are producing foodstuffs in country B. Unless they have some place else to dump their stuff and get some revenue for it, they risk going bankrupt.
This will not slip past unnoticed. You can expect tariffs, economic sanctions, and even state enforced boycotts against wares, services and companies from country A to stave off this sort of behavior, long before people start gaining weight.