The fact that $f$ and $g$ have limits at the points means that we can define two functions $\tilde f$ and $\tilde g$ that are continuous at $p$ and $q$ respectively, and otherwise equal to $f$ and $g$. Now assume that
- $g$ is defined at some value in the image $f(\omega'_p)$ of all punctured neighborhoods $\omega'_p$ of $p$,
- if $g$ is defined and discontinuous at $q$, then $f(x)\ne q$ for all $x$ close enough to $p$ (i.e. in some punctured neighborhood around $p$).
The first condition means that $g\circ f$ takes values around $p$ (and I included it since you allowed for partially defined functions). The second condition ensures that $g\circ f$ is equal to $\tilde g\circ\tilde f$ close to $p$. But then
$$
\lim_{x\to p}g(f(x)) = \lim_{x\to p}\tilde g(\tilde f(x)) = \tilde g(q) = Q.
$$
Conversely, note that the first condition above is necessary to even define the limit of $g\circ f$ at $p$.
For the second condition, assume that the implication holds, that condition 1 holds, that $g$ is defined at $q$, and that $(x_n)_n$ is a sequence converging to $p$ with $x_n\ne p$ and $f(x_n)=q$ for all $n$. Then
$$ g(q) = \lim_{n\to\infty} g(f(x_n)) = \lim_{x\to p}g(f(x)) = Q,$$
showing that $g$ is continuous at $q$. This shows that the second condition is necessary.
In conclusion, your implication is equivalent to the two conditions.