Let $f:A\rightarrow B$ be a homomorphism of noetherian rings which makes $B$ into a finite $A$-module. Under what conditions on $f$, $A$, $B$ can one associate to this map a canonical "trace map" $$\mathrm{Tr}_f:B\rightarrow A,$$ i.e. a homomorphism of $A$-modules $B\rightarrow A$ which is compatible with base change (perhaps with restrictions on the kind of allowable base changes), localization, and which recovers the "usual" thing when $B$ is free over $A$ (i.e. $\mathrm{Tr}_f(b) =$ the trace of the $A$-linear endomorphism given by multiplication by $b$ on the finite $A$-module $B$)?
Here are my thoughts so far:
1) If $f$ is flat, one always has $\mathrm{Tr}_f$. Just work locally, using that finite flat over a noetherian local ring is free.
2) More generally, if $f$ is of finite Tor-dimension, I can construct $\mathrm{Tr}_f$ by taking a finite projective resolution
$$0\rightarrow P_n\rightarrow \cdots\rightarrow P_0\rightarrow B\rightarrow 0$$
of $B$ as an $A$-module: lift multiplication by $b$ on $B$ to a map of complexes $b:P_{\bullet}\rightarrow P_{\bullet}$ and define $$\mathrm{Tr}_f(b) := \sum_i (-1)^i \mathrm{Tr}_i(b)$$ where $\mathrm{Tr}_i(b)$ is the trace of the (lift of the) endomorphism $b$ of $B$ to $P_i$. One chekcs this is independent of the choice of projective resolution. It commutes with "tor-independent" base change (sometimes called "cohomologically transverse" base change).
3) If $A$ and $B$ are normal, I can construct $\mathrm{Tr}_f$ as follows: the localization of $f$ at any height-1 prime ideal is automatically flat by Matsumura 23.1 as the corresponding localizations of $A$ and $B$ are regular and the dimensions work out (the fiber ring is 0-dimensional as $f$ is finite). Thus, one has a canonical trace map on each localization, and since $A$ and $B$ are normal, they are the intersections of these localizations so we win.
4) If $A$ and $B$ are only assumed reduced, one can look at the injections $A\rightarrow A'$ and $B\rightarrow B'$ with $A'$ and $B'$ the normalizations of $A$ and $B$ in their total rings of fractions. Let $f':A'\rightarrow B'$ be the corresponding map. By 3), we get a trace map for $f'$ and the whole problem of constructing the trace map for $f$ comes down to showing that $\mathrm{Tr}_{f'}$ carries $B$ into $A$. Letting $C_A:=\mathrm{ann}_{A'}(A'/A)$ be the conductor ideal (with $C_B$ defined similarly), I think that a necessary condition for $\mathrm{Tr}_{f'}(B)$ to be contained in $A$ is $$f'(C_A) \supseteq C_B.$$ Is this condition sufficient? As an example of how things can go wrong if this condition is violated, consider the finite map between reduced $k$-algebras ($k$ a field) $$k[x,y]/(xy) \rightarrow k[x]$$ given by sending $y$ to 0. The normalization of $k[x,y]/(xy)$ is the product $k[x]\times k[y]$ and the trace map attached to $f':k[x]\times k[y]\rightarrow k[x]$ sends $b\in k[x]$ to $(b,0)$. But $(b,0)\in k[x]\times k[y]$ lies in the image of $k[x,y]/(xy)\rightarrow k[x]\times k[y]$ if and only if $b(0)=0$. It follows that the trace map on normalizations doesn't restrict to a trace map on the original rings.
I'd be happy to assume that $A$ and $B$ are flat $R$-algebras, for a regular local ring $R$, and that $f:A\rightarrow B$ is an $R$-algebra homomorphism. I'd also be happy to assume that $A$, $B$, and $f$ are local, with $A$ and $B$ reduced complete intersections over $R$. I'm wondering if there is a framework for trace maps in this context that is general enough to handle the different constructions given in 1) -- 4) above.