110527-1213 EDT
From a technical perspective you do not use a switch but rather a grid-tied-inverter. The grid-tied system automatically distributes the energy from the inverter and the grid to the load, or into the grid.
Basically you have a voltage source with an internal impedance feeding the house (the grid) on the grid side of the KWH meter, and a current source with a maximum current (the inverter) also feeding the house on the house side of the KWH meter.
When the house load is greater than the inverter capability, then the house is supplied by both the grid and the inverter.
When the house load is less that the inverter capability, then the inverter supplies all of the house load, and feeds the balance of the inverter capability to the grid. The grid is the moderator of the load voltage even when energy is being fed to the grid.
This automatic balancing results from current levels, voltage levels and internal impedances,
In some other thread I tried to provide a simple explanation of how this works.
In the real world because of contracts, rules, regulations, and laws you many not be able to do legally what you can do technically.
.