I’ve made a cube with 3 light sources placed at x, y and z axis. how to turn it OFF and ON Individually ie. R to toggle Red, G for green and B for Blue.

How to hide the image in dark. when a light is on only selected part is visible.

Assuming that your 3 lights are GL_LIGHT0, GL_LIGHT1, and GL_LIGHT2. Then to turn on GL_LIGHT0, just call glEnable (GL_LIGHT0)…
And to turn off GL_LIGHT2, call glDisable (GL_LIGHT2).