What is the recommended method for programmatically editing or inserting values into the field_data_* tables?
If you want to create users belonging to a group (able to publish content under the group, see group content), og_group() should do the trick; I'd check your implementation and make sure it's ok before going too far astray. I'm doing the exact same thing with the following code and it's correctly inserting the group_audience values into the field_data_group_audience table.

og_group($group_id, array('entity' =&gt; $account));


However, if you're totally stuck and want to try another route, you can always manually insert the data through db_insert().