So first you have to go right, so that introduces a factor of $p$. After that, you need to hit $a$ before hitting $0$ starting at $1$. There is a standard way to compute the probability to do that, based on computing the probability to hit $a$ before hitting $0$ starting at every point in $0,1,\dots,a$. The idea is the total probability formula:
$$P(\tau_a<\tau_0 \mid X_0=k)=p P(\tau_a<\tau_0 \mid X_0=k+1) + q P(\tau_a<\tau_0 \mid X_0=k-1).$$
So if $u(k)=P(\tau_a<\tau_0 \mid X_0=k)$ then you have the equations
$$u(k)=pu(k+1)+qu(k-1)$$
for $k=1,2,\dots,a-1,u(0)=0,u(a)=1$. (Note that $u(0)$ is not the quantity that you want; you actually want $pu(1)$. This is an annoying thing about the distinction between "hitting" and "returning".)
This system can be solved; the solution is of the form
- $u(k)=c_1 + c_2 \left ( \frac{1-p}{p} \right )^k$ if $p \neq q$
- $u(k)=c_1 + c_2 k$ if $p=q$.
Using the BCs you can find $c_1,c_2$.