Question: What are viral vectors used for in optogenetics?

Context:
To express ChR in neurons, the common expression systems include viral vectors, in utero electroporation, and transgenic animals, each with their advantages and limitations regarding the cost, expression pattern, and the required effort. 
In this review, the various strategies for selective genetic targeting of a defined neuronal population are discussed as well as the pros and cons of the use of transgenic animals and recombinant viral vectors for the expression of transgenes in a specific set of neurons.
We demonstrate how the ability to target astrocytes with cell-specific viral vectors to express optogenetic constructs helped to unravel some previously unsuspected roles of these inconspicuous cells.
Optogenetics, the use of light to stimulate or inhibit neural circuits via viral transduction of protein channels, has emerged as a possible method of treating epilepsy.
We demonstrate how the ability to target astrocytes with cell-specific viral vectors to express optogenetic constructs helped to unravel some previously unsuspected roles of these inconspicuous cells.
We conclude that a viral vector approach with a strong promoter is required for successful optogenetic stimulation of distal axons to evoke transmitter release in pre-autonomic PVN neurons.
RESULTS: Extracellular single-unit recordings were made from infralimbic (IL) pyramidal cells, IL interneurons and prelimbic (PL) pyramidal cells 2-3 weeks after intra-IL injection of a viral vector encoding channel rhodopsin 2 (ChR2) under the control of the CaMKII promoter (rAAV5/CaMKIIa-ChR2(H134R)-EYFP) or a control vector that lacked the ChR2 sequence (rAAV5/CaMKIIa-EYFP). 
We conclude that a viral vector approach with a strong promoter is required for successful optogenetic stimulation of distal axons to evoke transmitter release in pre-autonomic PVN neurons. 
We selectively expressed ChR2(H134R) in rostral VLM catecholaminergic neurons by injecting Cre-dependent adeno-associated viral vectors into the brain of adult dopamine-β-hydroxylase (DβH)(Cre/0) mice. 
We developed driver and double reporter mouse lines and viral vectors using the Cre/Flp and Cre/Dre double recombinase systems and established a new, retargetable genomic locus, TIGRE, which allowed the generation of a large set of Cre/tTA-dependent reporter lines expressing fluorescent proteins, genetically encoded calcium, voltage, or glutamate indicators, and optogenetic effectors, all at substantially higher levels than before. 
We generated rabies glycoprotein-pseudotyped lentiviral vectors that use a positive feedback loop composed of a Tet promoter driving both its own tetracycline-dependent transcription activator (tTA) ("TLoop") and channelrhodopsin-2-YFP (ChR2YFP). 
Optogenetic control of cardiomyocytes via viral delivery.
Here, we used an optogenetic approach, in which female rats received bilateral dorsal mPFC microinjections of viral constructs coding light-sensitive eNpHR3.0-eYFP or control eYFP protein and intracranial fiber optic implants. 
We transduced rat LC neurons by direct injection of a lentiviral vector expressing channelrhodopsin2 under the control of the PRS promoter. 
Here, we describe the construction of a blue-light-induced K(+) channel 1 (BLINK1) engineered by fusing the plant LOV2-J� photosensory module to the small viral K(+) channel Kcv. 
In parallel, remarkable success in the development of highly efficient viral vectors for ocular gene therapy led to new strategies of using these novel optogenetic tools for vision restoration.  These recent findings show that novel optogenetic tools and viral vectors for ocular gene delivery are now available providing many opportunities to develop potential optogenetic strategies for vision restoration.

Answer: Viral vectors are used to express optogenetic constructs in selected cells.