It's not a case of, "it's better to have ATPL/CPL theory before you commence your commercial flying training" but a matter of, "you must have passed your commercial theory before you sit your skill test for CPL"
In JAA land anyway!!
On a modular programme therefore, you would generally commence groundschool after PPL and during your hour-building phase.
Cheers
Whirls