You might probably want to install Canonical URL’s for WordPress (WordPress Plugin). It allows you to specify a canonical URL for each post and page. So you can configure the way you want.
The plugin is not big, you probably can integrate the functionality easily into your theme then.