There have been contradictory guidelines from WotC on this. For the longest time, the "official" interpretation (from the FAQ, IIRC) was that it was a free action to both take one hand off and put it back on your weapon. So you could easily cast spells while wielding a two-handed weapon, and gain all the benefits of the weapon while not casting (i.e. during everyone else's turns).
Then later on in 3.5, one of the "Rules of the Game" articles contradicted this by saying that they "thought" it should be a move action to re-grip a weapon in two hands...
So basically, there are no rules addressing this, and WotC's suggestions have varied. So pick your poison.