It's a quotation (to which I somehow found myself alluding earlier in the week) that should, given its fame, be from some fictional work by Voltaire. However, my King's Classical and Foreign Quotations (1904) p 42 ascribes an altogether humbler origin.

(From memory, 1828 was around the time the Zoological Gardens in Regent's Park, London was established. Small world...)

The King's entry in full runs thus:

Cet animal est très méchantQuand on l'attaque il se défend

Théodore PK, (?) La Ménagerie: music by Edmond Lhuillier, Paris, (Petit, 18 rue Vivienne) 1828 - This animal (the leopard) is so vicious, that if you attack him he will defend himself!

Music-hall song of the day, burlesquing the recently published Histoire Générale des Voyages of C A Walckenaer, Paris (Lefèvre) 1826, whre an account is given (vol 1, p114) of the adventures of Vasco da Gama, and his comrades amongst some "sea-wolves" of an extraordinary size and armed with tremendous teeth. "Ces animaux", it proceeds, "sont si furieux, qu'ils se défendent contre ceux qui les attaquent." It is difficult to say which is the more ludicrous, the serious prose or the burlesque verse. [Reference to R Alexandre, Musée de la Conversation 3rd Ed 1897 pp19-20]