Fantasy, vaguely European middle ages. Humans are the only friendly intelligent species. Other species (and magic) exist but they're almost always things you work (or fight) against rather than forces on your side. Both the other species and magic are so varied that it tends to be a flavor-of-the-week sort of deal, and thus it is impossible to make long term-term plans for what threats are on the horizon.
Thankfully, mortal men are generally up to the task of dealing with these threats, and when either magic or species are a violent threat, the threat isn't big enough to warrant marching armies.
The kingdoms are very loosely knit where central regions are supported by mostly removed, small communities that provide agricultural and craftsmanship needs. The societies are very spaced apart, and borders are extremely poorly defined and enforced even worse. War is historically extremely rare, and armed forces are universally underdeveloped on all levels (small armies typically are only stood up when raiders, bandits, or the ilk threaten citizens).
Each small community (town and surrounding farmland)--one to three times a decade--deals with an until-then-unheard-of magical beast, wizard, etc. The threat could be eating the sheep, burning the crops, abducting children, or something else that demands that they beare dealt with. These threats are significant enough that the nations really need to put an end to them, but rare enough that the leaders can't justify stationing troops atin the towns. Still, the townsfolk can't deal with it directly, as it's dangerous enough that the inexperienced, ill trained-trained, and poorly armed citizens will face significant loss trying to deal with it themselves.
I want the world to have adopted a habit of communities hiring bands of mercenaries (or as they call them "hero bands") to deal with these time-to-time threats, but this leaves the obvious suggested transition to bandits and highway robbers when these hero bands are between jobs.
What is a policy a kingdom can adopt (within the restrictions of the historic period, and no hand waving with magic) that's an efficient and effective means of stopping these otherwise helpful bands of mercenaries from devolving into bandits, while not placing a strain on the coffers? Since not all of the bands of heroes are from the kingdom, social pressure or indoctrination methods would be fairly hit-and-miss.