Where do I place custom PHP code (functions, classes) when creating a theme?
The theme's template.php is used for logic and data processing. See the Drupal theming guide.

From the guide:


  For all the conditional logic and data
  processing of the output, there is the
  template.php file. It is not required,
  but to keep the .tpl.php files tidy it
  can be used to hold preprocessors for
  generating variables before they are
  merged with the markup inside .tpl.php
  files. Custom functions, overriding
  theme functions or any other
  customization of the raw output should
  also be done here. This file must
  start with a PHP opening tag "&lt;?php",
  but the close tag is not needed and it
  is recommended that you omit it.