Assign a node to an organic group
You're on the right track.
You also have to add a row to the og_ancestry table. Someone posted sample code for Drupal 6 here.

/**
 * Implementation of hook_nodeapi().
 */
function mymodule_nodeapi(&amp;$node, $op, $arg, $page) {
  switch ($op) {
    case 'insert':
      // let's autocreate a Wiki node for our Top wiki page when we create a Group
      if ($node-&gt;type == "group") {
        global $user;
        include_once (drupal_get_path('module', 'pathauto') .'/pathauto.inc');
        $path = pathauto_cleanstring($node-&gt;title);

        $wiki-&gt;type = "wiki";
        $wiki-&gt;status = 1;
        $wiki-&gt;uid = $user-&gt;uid;
        $wiki-&gt;name = $user-&gt;name;

        $wiki-&gt;title = $node-&gt;title . " Wiki";
        $wiki-&gt;body = t("This is the Wiki for your Community. Any member is allowed to edit this page. Be the first to edit this page by selecting the EDIT tab above and deleting this content and replacing it with your own.");
        $wiki-&gt;path = "wiki/" . $path;
        $wiki-&gt;og_initial_groups[0][$node-&gt;nid];
        $wiki-&gt;og_groups[0] = $node-&gt;nid;
        $wiki-&gt;og_public = 0;
        $wiki-&gt;og_groups_names[0] = $node-&gt;title;

        if ($wiki = node_submit($wiki)) {
          node_save($wiki);
          $sql = "INSERT INTO {og_ancestry} (nid, group_nid) VALUES (%d, %d)";
          db_query($sql, $wiki-&gt;nid, $node-&gt;nid);
        }
      }

      break;    
  }
}