It's not that he was on the way to work at the time. It was that he was performing a duty required by his work at the time. He is expected to buy these treats for work, with work money, thus he is represent his company. As a representative of his company, he needs to act as such, and thus he is bound by the code of conduct.
He's hoping that since he is a representative of the company, and is bound by the code of conduct, that he'll be able argue that his bike would not have been stolen while performing work duties. That this bakery or what not should be considered an extension, of his work area.
It's closer to the logic that if you are sent on business to another country, and are mugged, is the office responsible.