Intersection Theory on a Surface
We want to show that if $C,D$ are two curves on a regular surface $X$ such that $C$ does not contain any associated point of $D$, then $\mathcal{O}_C(-D) \rightarrow \mathcal{O}_C$ is injective.
As you suggested it suffices to check this on stalks.
Let $A=\mathcal{O}_{X,c}$, and let $f,g \in A$ be local equations for $C,D$ respectively. Then we want to show that the map $A/(f) \rightarrow A/(f)$ given by multiplication by $g$ is injective. It suffices to show that $g\in A/(f)$ is not a zero-divisor.
Suppose otherwise, then there exists $0\ne a\in A/(f)$ such that $ag \in (f)$, i.e. $ag = bf$ in $A$ for some $b\in A$. Let's use the fact that $A$ is a UFD (as it is regular). If $g$ and $f$ do not share any common factors, then $a=0 \in A/(f)$. Therefore we may assume that $g$ and $f$ shares some common factor $h\in A$.
Now let's lift this result to an open set on $X$.
By a suitable localisation (i.e. take an affine open containing $c$, and then invert everything that shows up in the denominators in the above), we may assume that $X$ is locally given by $\operatorname{Spec} A'$, $f,g,h \in A'$ and that $g = g'h, f=f'h$ in $A'$ for some $f,f'\in A'$. But this implies that $V(h) \subseteq V(g) \cap V(f)$ in $\operatorname{Spec} A'$. Since $A'$ is an integral domain, $V(h)$ has dimension one. So this implies that $V(g)$ and $V(f)$ share an irreducible component on $\operatorname{Spec} A'$, which implies that they share an irreducible component on $X$. This gives a contradiction.
Note that we actually only used the fact that $C,D$ do not share irreducible components and nothing about embedded points - but as Vakil mentions right after this exercise - in fact $D$ is never going to have embedded points since $X$ is smooth.
I think you want to assume that $S$ is regular, so that $(\mathcal{O}_{X,c})$ is factorial. So we have a factorial ring $R$, and elements $f$, $g$ which cut out $C$, $D$. Since $C$, $D$ do not have common components, we $f$, $g$ are coprime---$\text{gcd}(f,g) = 1$. Now, we want to show that$$f: (gR)/f(gR) = \mathcal{O}_{C,c}(-D) \to \mathcal{O}_{C,c} = R/f\text{ is injective.}$$
To see this, take $g a \in g R$, with $g a = 0$ mod $f$. So $g a = f b$. So $f \mid (g a)$. Since $f$, $g$ are coprime, we have $f \mid a$. Hence $a = c f$, and $g a = g f c$, so $g a \in f g R$.
The best reference for this I know of is Beauville's book Complex Algebraic Surfaces, Chapter 1.
Update: Let's try a second explanation. Concerning your question, you are probably almost there. The issue is that the formula should hold whenever $C$ and $D$ "intersect properly". If say, $X$ is regular, $C$ and $D$ are reduced, this exactly means that $C$ and $D$ have no common irreducible components. In general, we need $C$ and $D$ to be Cartier divisors in $X$, and that $C \cap D$ remains a Cartier divisor in say, $D$. The last condition means that no associated point of $C$ is contained in $D$, or equivalently, that locally $f$ is a nonzero divisor in $\mathcal{O}_{X,c}/(g)$. So multiplication with $f$ is an injective morphism in $\mathcal{O}_{X,c}/(g)$, which looks like what we need.