You don't connect the ground together, that's the whole point of opto-isolation.
(you should still connect the earths to the PC and lathe at their plugs)

The current flows out of the 5v from the PC's USB (or keyboard connector ) through the LED in the opto-isolator then back into the PC via the printer port (the printer port driver device or breakout board is happy to 'sink' the 10-20mA required to light the LED).