Code in the template or in a module? Is it better to write hook functions in template.php (or a .inc in my theme folder) or is it better to put them in custom modules?  Or, does it matter?  Is it just a matter of organizational preference?  Does it depend?
Id say its simple case of organisation and relevance. Hooks fit into three different categories, alter, process and theme so probably best to organise these into separate include files.

inc/
template.alter.inc
template.process.inc
template.theme.inc


If your going to add a class to a button in a certain contrib module or similar then obviously creating a custom module is overkill. 

Probably the best strategy to have is to work on the theme layer and it will soon be apparent if its worth putting the relevant code into its own module. Either way, you have achieved what you wanted.

Does it matter where the code is? Probably not, it's a few checks or calls wherever it is. Your probably get many an argument on best practices from various developers on this.