Note that the simplest solution may be net metering.Where permitted, this uses inverters that monitor and synch with the power lines, and therefore can be connected in parallel with the grid. At the same time, your meter is replaced with one that can count both forward and backward; if you are producing more power than you need the excess gets sold to the grid, and when the balance goes the other way (eg at night), or when clouds cut your production) you buy power.
Major advantages include continuous aitomatic balancing of the two sources, no need to maintain a battery bank, and the joy of the midsummer bill when the power company may owe you money. (I haven't quite gotten a negative bill yet -- I've gotten negative grid usage, but not enough to overcome the $6/month account fee.)
Disadvantage is that, for safety reasons, these systems are designed to shut down when power is lost on the grid to avoid the risk of electrocuting someone who would have expected the downstream end of the break not to have voltage on it.
Theoretically it would be possible to run disconnected (in "island" mode"), but them you'd need to re-introduce transfer switches for safety, and you'd need a 60Hz 240-split reference for the inverters to sync to. I can imagine a setup where you'd disconnect from the grid and connect instead to a generator as "local grid reference", with the solar panels and the generator sharing the load... but that has complications in protecting the generator from reverse current, and it isn't a approved/supported configuration for any manufacturer I'm aware of. Maybe someday...
Anyway, I just wanted to toss the out as an alternative to explicitly switching between solar and grid. Depending on your goals and needs, it may or may not be the best answer.
It actually depends on whether the ground is going to be installed ahead of the main breaker or if it is installed after the main. Most of the contractors I know will install a #6 simply because it is less expensive to stock one size than two and it covers everything up to a 200A main. So I would go with a #6. 2014 NEC reference Tables 250.102(C)(1) and Table 250.122.
Use extreme caution when working around panelboards. I recommend DIYers make sure the panel is disconnected from all power sources before performing any work.
Hope this helps.
Best Answer
Short answer. Your fine to upgrade to a 40A breaker. Remember the breaker is being used to protect the feeder conductors. If you feel you need to use the breaker to protect your inverter you should install protection just before the unit.