Are you only selling to outside retail sources or are you selling to the public also?
If you are selling whole cakes directly to them and they are selling them by the slice, then there isn't much you can do about it except cancel out. Are they also advertising your company as the source of the cakes, or are they just generically selling them? If they are generically selling them, there isn't anything to worry about, as the customer will think it was made on premises.
If you are selling individual slices that YOU package, and they are reselling them, then you can put your own label on it with a specific "sell by" date.
I ate at one place that bought pies from a local elderly couple, cut them up, wrapped them in plastic and sold them as they were. They never lasted long. I think they told me that three days worth of making pies would sell out before the weekend was even half over.
If you want to avoid this kind of thing in the future, you need to stipulate your criteria for selling your product in your agreements or contracts, especially if they keep your name on it. If you find out they are violating your contract stipulations, then you have the right to immediately terminate the contract.
You could also work a "buy back" into your contract or agreement. This is when an outside source is purchasing your product for resale, and anytime there are left overs past the expiration date, they can return them to you for "buy back". This keeps YOU in control of the shrinkage and stale dated products. Using this method, you either buy back what didn't sell after it expires and throw it out yourself, or donate it to someplace that needs foodstuffs, or you throw it away and give the retailer a discount on the next fresh supply.
Whatever you do, you have to word your agreement or contract carefully as to avoid any confusion on either side, and then verbally state to them in person what the verbiage means in the contract. And be sure and have at least 2 witnesses to anything verbal.