How does optogenetics work?
Short answer 

Optogenetics can be used to make cells responsive to light. One striking use of this technology is to restore vision in the blind by making the surviving neurons in the retina light-sensitive. This can be done by transfecting the retina with genetically engineered viruses that induce the expression of bacterial channelrhodopsin proteins in retinal neurons.

 
Background  

I will explain optogenetics by focusing on one of the most striking applications: to make the blind see. In humans light is sensed by photoreceptors in the retina (see further reading #2). Rods infer grey-scale vision (i.e., night vision), while cones provide color vision when there is enough light available. Rods and cones contain light-sensitive proteins: the photopigments. The pigment in rod photoreceptors is called rhodopsin, in cones they are referred to as cone pigments, which are used for color vision. When light hits the rods and cones, the photopigments catch the light and activate a cascade of second messenger reactions, eventually causing hyperpolarization of the membrane. This hyperpolarization in turn activates secondary neurons in the retina, which eventually carry the receptor signal to the brain, where it is processed and used to generate a visual percept. 

Light sensing across single-celled and multicellelar animals is mediated by two large families of proteins: the opsins. Opsin genes are divided into two distinct superfamilies: microbial opsins (type I) and animal opsins (type II). The rohodpsin and cone pigments found in humans belong to type II. Among other differences, type I opsins are bound to ion channels, while type II is not. Type II opsins therefore need a battery of intracellular second messenger molecules to operate. In contrast, the type I opsins, being channel proteins, directly cause intracellular changes by changing the membrane potential upon activation due to ion flow. Type I opsins, being channel proteins are referred to as channelrhodopsins.

In retinal degenerative diseases such as retinitis pigmentosa (RP) the photoreceptors degenerate and patients eventually loose their vision. The secondary neurons in the retina, however, partly survive. As explained above, these secondary neurons are responsible for processing the photoreceptor signal and sending it to the optic nerve. Hence, although RP patients miss the photoreceptors, the rest of the visual pathway is ready to rock! Hence, somehow these neurons should be activated. There are a battery of approaches to do just this. Retinal implants activate the neurons directly by electrical activation (see further reading #3). 

Optogenetics (Fenno et al., 2013) is another approach where the secondary surviving neurons are made photosensitive, thereby bypassing the photoreceptors by turning the secondary neurons into photoreceptors. The neurons are made photosensitive by making them express channelrhodospins. This is done by injecting a viral vector into the eye such that the virus infects the retinal cells. Instead of a viable virus, however, it is tinkered aound with and the only thing the virus does is incorporate the channelrhodopsin into the genome of the neurons, which start to express it.

Channelrhodopsins are cation channels, and therefore, upon light activation, they allow positively charged ions (notably Na+, but also Ca+) into the cell. This depolarizes the neuron and can induce action potential firing (see further reading #1). Action potentials is the neuron way of transmitting signals to the brain. Hence, by activating the secondary neurons through channelrhodopsin transformation, they start sending light-induced neural activity to the brain. The brain will handle this input as if evoked by photoreceptors and hence will interpret it as light-evoked visual stimuli.

With regard to cancer: It has been shown that expression of channelrhodopsin and illumination of whole-mice resulted in diminished subcutaneous cancer cell counts (yang et al., 2013). 

With regard to your first added question: dependent on the exact peptide regulatory sequences added to the protein, or by using viral vectors specifically targeting axons, expression of channelrhodopsins can occur wherever one likes.

Your second added question: Cation channels activate neurons, anion channels inhibit them. This means you can play around with different variants to control neurons at will. 

 

References
Fenno et al. Annu Rev Neurosci 2011;34:389–412
Yang et al. Cell death and disease 2013;4:e893


Further reading
 1. Action potentials and neurons: how-do-the-brain-and-nerves-create-electrical-pulses
 2. Photoreceptors: parallels-between-pixelized-image-and-the-human-retina
 3. Retina and retinal implants: does-the-retina-encode-visual-information-like-a-bitmap-or-an-svg