It’s unclear, and ultimately you’ll have to ask your GM. It seems unlikely that the authors would have bothered requiring a free hand if it was intended to be so easy to work around that limitation, but that is speculation on my part. The official rules themselves do not give us enough information to be sure.
The issue is that it says
To use this ability, the magus must have one hand free [...] As a full-round action, he can make all of his attacks [...] and can also cast [...]
So the hand must be free for “this ability,” and “this ability” is defined as the full-round action taken to attack and cast. You can take free actions in the middle of full-round actions—that is, it is possible to grab the weapon with your other hand in the middle of your spell combat—but it isn’t clear what happens if you do that.
This is part of a broader under-specification in the rules: do things that have some requirement get interrupted if that requirement is lost in the middle of it? For example, if a spell changes an elf into a fiend, does an existing charm person effect “fall off” them (since charm person could not target a fiend in the first place)? There are games that explicitly get into these kinds of questions, but Pathfinder isn’t one of them. So, likewise, we don’t know—don’t even really have firm precedent for—whether or not losing a free hand in the middle of spell combat somehow messes up spell combat. For that matter, if it does mess things up—and as I speculated above, this does seem the more reasonable expectation—what exactly happens?
Personally, I would probably say the most consistent ruling is to say that, in that case, you are no longer using spell combat, and as a result you are either making a full-attack, or you are casting a spell. If you’re making a full-attack, you get all your attacks, but don’t cast any spell. If you’re casting a spell, you only use a standard action, but you don’t get any attacks. If you have already cast the spell and already made one or more attacks, then instead your action just ends and you give up any remaining attacks. The rules don’t specify this but it seems like the most consistent way to rule things in my view.
That said, to get even more subjective/personal, I personally don’t see a whole lot of value in the free hand requirement on magus. I don’t think it adds very much to the game. I’m happy enough to waive it most of the time—magus is a decent enough class, but it certainly isn’t especially high-power, and it doesn’t bother me to allow them to do use a two-handed weapon. For that matter, it doesn’t bother me to allow them to dual wield, either. I’m fine with a magus performing somatic components with a weapon in hand, that seems reasonable for someone with their specialized training. This is emphatically not the rules—it appears the authors did have problems with magi doing those things—but personally I’m fine with giving them as a buff.