I believe that what you wrote is not entirely correct and that might be the reason that it does not seem to work out. As a response to one of your comments, $K_C$ actually makes sense in this case, because it is a Cartier divisor in $S$ and hence Gorenstein. I'll elaborate on this below.
So, I don't think $\frac{1}{f} dx \wedge dy$ generates $\mathscr O(K_S)$ (locally). If you think about it, essentially by definition $dx \wedge dy$ generates that sheaf (locally), so the additional $\frac 1f$ gives it a twist. My guess is that what you saw said that $f$ should be a local equation for $C$ and if it is that then $\frac{1}{f} dx \wedge dy$ generates $\mathscr O(K_S+C)$ locally. If this is OK with you, then it is no surprise that its restriction to $C$ generates the restricted sheaf.
And, indeed, there is a more general framework for this. Using your notation, let $V$ be a Cohen-Macaulay (CM) scheme (or variety, or complex analytic space) and let $D\subseteq V$ be an effective Cartier divisor (this can be weakened to $D$ being a pure codimension $1$ subscheme/subvariety, but in that case you have to be a bit more careful about the sheaves that appear, so I'll stick to this case for simplicity).
I will use the notation $\omega_X=\mathscr O_X(K_X)$ for any $X$ for which this makes sense.
Then we have a short exact sequence:
$$
0\to \mathscr O_V(-D)\to \mathscr O_V\to \mathscr O_D \to 0
$$
The long exact $\mathscr Ext$ sequence associated to the functor $\mathscr Hom_V(\__, \omega_V)$ (and the fact that $V$ is CM) gives the
short exact sequence:
$$
0\to \omega_V\to \omega_V(D)\to \omega_D \to 0
$$
The map $\omega_V(D)\to \omega_D$ is essentially what you are looking for and can be interpreted so that $\omega_V(D)|_D\simeq \omega_D$.
If $V$ is Gorenstein and $D$ is a Cartier divisor (then $D$ is also Gorenstein), then all of these sheaves are locally free of rank $1$ on their support, so you can find local generators that look pretty much the ones you wrote down. If $V$ is smooth, then it is Gorenstein and then every codimension $1$ subvariety is a Cartier divisor, so this covers the case you were wondering about.
A few explanations, mainly sparked by the questions in the comments:
The canonical sheaf, Hom long exact sequence, and all that jazz: I wasn't entirely sure how much to include and what generality to go to. The formula involving Ext and projective space and the codimension of V in that projective space is a special case of Grothendieck duality and it holds any time a Gorenstein scheme is contained in another. (The proper way to write this would be writing out the "usual" (total) derived functor format and then take cohomology of that). In any case, this implies that $\omega_D\simeq \mathscr Ext^1_V(\mathscr O_D, \omega_V)$ if you start writing out the Hom-Ext sequence, the first Hom will be zero, then you have two terms (the first two terms of that ses) and then this Ext. All other terms are zero, because if the first term is locally free, then all higher Exts are zero. This is how you get that short exact sequence.
As far as using the Ext formula vis-a-vis the projective space, you can do that, you'll get the same thing. Grothendieck duality is nice in this regard, it is natural, so you can apply it consecutively for a composition. This is actually a nice exercise if you have never done it.
Being Gorenstein is equivalent to being CM and the canonical sheaf being locally free of rank 1. The definition of CM implies that (local) hypersurfaces inherit being CM (essentially the definition of depth does this). And the above short exact sequence implies the local freeness of the canonical sheaf.