The earliest uses I can find are 1816 and 1820 and include the four.
Here's Charles Taylor in 1816, in Facts and evidences on the subject of Baptism in three additional letters:
How slightly do some very good people
read their Bibles! — .The Scripture is
plain enough, to proper attention. Any
who can put two and two together, to
make four, may, and indeed must
understand it.
Here's William Cobbett in 1820, in Cobbett's Weekly Political Register: Volume 36:
I am no lawyer, and if it were
possible, still less of a conjuror,
but, being able to put two and two
together, and to ascertain that they
make four; being able to arrive at
this conclusion, with mathematical
certainty ...
And even more interesting, from the same volume:
My opinions have not often been
contradicted by events ; and my
decided opinion is, that, when you and
your colleagues have carefully put two
and two together ; and then put a one
to the four, and by the total have
multiplied twenty, the result will
show you that it would much better not
to proceed with the trial any more
than with the Coronation.
Both from very similar times.
It's interesting to find some instances of putting two and two together in a literal sense, such as this 1820 example of how to pot and collar eels in The practice of cookery, pastry, confectionary, pickling, preserving, &c By Frazer (mrs.)
After taking off the skin, split them
down from the shoulder to the tail,
and bone them ; season them highly
with salt, spices, and sweet herbs ;
then put two and two together, with
the shoulder of the one to the tail of
the other;