Where do I connect earth wire?
You must connect any existing earth ground wires directly to the earth ground connection. Not doing so could be a violation of safety regulations and/or civil code.

While you're at it, put that timer in a proper box. As it is, it is very easy to come into contact with a hot connection (which is a violation of the above in its own right).