The worst mass to have on your bicycle is rotating mass, because you must overcome both rotational inertia and "regular" inertia to get the bicycle moving forward. Of course you don't mount the locks on the wheels, so that's not a factor.
If your bicycle had a suspension system, then the next worst kind of mass would be unsprung mass, that being mass that has to bounce up and down on bumps. You have to provide the energy to move the mass up and down, of course. Your bicycle doesn't seem to have a suspension other than the pneumatic tires, so that's also not much of a factor.
If you ride very steadily without bouncing up and down on the saddle, then there might be a slight performance gain from keeping the lock in your backpack. However, if you get off the saddle to stand and pump the pedals, then you might lose performance. Personally I think that any small performance gains you might see from keeping the lock in your backpack would be dwarfed by the discomfort of having a weight in the pack that you might otherwise more comfortably mount on your bicycle frame, so if it were me I would probably elect to keep the locks on the frame.
You could always experiment: try a week or two with the locks on the frame and measure your times on your usual commute, and then try another week or two in the pack. If you do experiment, please report your findings as an answer to your own question. (It's fine to answer your own question, and even accept your own answer if you think that it's the best answer.)