This question has been previously considered in this thread. Here's a recap:
Robin Chapman gives a reference to the freely-available paper When are Associates Unit Multiples? by Anderson, Axtell, Forman and Stickles.
In the paper, the following notation is used: Let $R$ be a commutative ring. If two elements $a, b \in R$ satisfy $a\mid b$ and $b\mid a$, then they are called associates and we write $a\sim b$. If two elements $a, b\in R$ satisfy $a=u b$ for some unit $u$, then they are called strongly associates and we write $a\approx b$.
OP's question seems to be: Which elements $a, b\in R$ in the ring satisfy $a\sim b$?
It is clear that if $a\approx b$, then $a\sim b$ (see comments above). The paper above by Anderson et al. aims to describe (among other things) the commutative rings $R$ in which $a\sim b$ implies $a\approx b$ for all $a, b \in R$. If $R$ is an integral domain, then this is clearly true. (See Timothy Wagner's answer).
Here is a more general theorem due to Kaplansky:
If $R$ is principal ideal ring, or Artinian ring, or a ring satisfying
$Z(R )\subset J(R )$ (here $Z(R )$ is the centre of $R$, and $J(R )$
is Jacobson radical of $R$), then $a\sim b$ implies $a\approx b$ for
all $a, b \in R$.