The preprocess functions can be implemented from modules, and themes.

The preprocess function that you need is `hook_preprocess_html()` and the variable to set is `$variables['classes'], which is a string containing all the classes set for the `<body>` tag.   The content of the [html.tpl.php][1] file that is used by default by Drupal (if the theme doesn't use a different template file) is the following one:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
      "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>"<?php print $rdf_namespaces; ?>>
    
    <head profile="<?php print $grddl_profile; ?>">
      <?php print $head; ?>
      <title><?php print $head_title; ?></title>
      <?php print $styles; ?>
      <?php print $scripts; ?>
    </head>
    <body class="<?php print $classes; ?>" <?php print $attributes;?>>
      <div id="skip-link">
        <a href="#main-content" class="element-invisible element-focusable"><?php print t('Skip to main content'); ?></a>
      </div>
      <?php print $page_top; ?>
      <?php print $page; ?>
      <?php print $page_bottom; ?>
    </body>
    </html>

In your module you just implement the preprocess function as follows:

    function mymodule_preprocess_html(&$variables) {
      $variables['classes_array'][] = "new-class";
    }

[template_process()][2] then uses `$variables['classes_array']` to populate `$variables['classes']` with the following code:

    $variables['classes'] = implode(' ', $variables['classes_array']);

&nbsp;<!-- break -->

Using a preprocess function in a module is preferable if your site uses more than one theme, or if the theme set for your site is not the one you created. In this case, you are able to set your custom CSS classes, and not lose them when updating the theme, or simply changing the default theme used by your site.  
If your site uses just a theme, and that theme is a custom theme you created, then you can implement the preprocess function in your custom theme. As you maintain the theme, the CSS classes are not lost when updating your theme.


  [1]: http://api.drupal.org/api/drupal/modules--system--html.tpl.php/7
  [2]: http://api.drupal.org/api/drupal/includes--theme.inc/function/template_process/7