--- This is attributed to Joel Garreau on quotefancy:
“The Harvard Law of Animal Behavior holds that under controlled experimental conditions of temperature, time, lighting, feeding, and training, the organism will behave as it damn well pleases.”
It's widely seen on the internet in variant forms, e.g. this from Philip Ball on Aeon: "Under carefully controlled experimental circumstances, the animal behaves as it damned well pleases."
Brembs in "Towards a scientific concept of free will as a biological trait: spontaneous actions and decision-making in invertebrates" in Proc Biol Sci. 278(1707), doi: 10.1098/rspb.2010.2325, cites to: Grobstein P. 1994. Variability in behavior and the nervous system. In The encyclopedia of human behavior (ed. Ramachandran V. S.), pp. 447–458 New York, NY: Academic Press, but I think this is to further support the claim the quotation is used to illustrate.