Assume that $p$, $q$, $a$, and $b$ are positive integers. By dividing $a$ and $b$ by $\gcd(a,b)$ (found, say, by using the Euclidean Algorithm), we may further assume that $a$ and $b$ are relatively prime. Similarly, we may also assume that $p$ and $q$ are relatively prime. If they are not, first divide each by $\gcd(p,q)$.
So from now on assume that $\gcd(a,b)=\gcd(p,q)=1$.
Then $\left(\dfrac{p}{q}\right)^{a/b}$ is a rational number if and only if the exponent of each prime in the prime factorization of $p$ and of $q$ is divisible by $b$. Equivalently, $\left(\dfrac{p}{q}\right)^{a/b}$ is a rational number iff each of $p$ and $q$ is a perfect $b$-th power.
The Euclidean Algorithm is cheap and fast. That is not the case for factorization. However, by a suitable adaptation of Newton's Method, we can find out efficiently whether $p$ and $q$ are perfect $b$-th powers. We can also do it by adapting the old algorithm for square root that used to be taught in the schools. Detecting whether something is a $b$-th power can be done in not much more than linear time.