I noted that this can be further confusing if you have a group with joined geometry inside it.
objGrp = bpy.data.objects.new(scn.baseName, None)
if objGrp has children that have there own origin set wrong sleecting it in the view will still have the origin wrong while the group parent object might be fine.
In this case you simply need to make sure you've selected the internal object first and the same will apply.
So Center of Mass etc. will work as expected on the kid too.
Here we see this situation where a bunch of generated objects are joined and then have the center set. Still maybe you want to loose the parent object at that point but it's just an example of how the Question poster (or others with this variation) might have not see the desired effect.
obs = objGrp.children
ctx = bpy.context.copy()
ctx['active_object'] = obs[0]
ctx['selected_objects'] = obs
ctx['selected_editable_bases'] = [scn.object_bases[ob.name] for ob in obs]
ob = bpy.ops.object
ob.join(ctx)
obs[0].select = True
ob.origin_set(type='ORIGIN_CENTER_OF_MASS')