Suppose $q\mid p-1$ where $p,q$ are two distinct primes. Also let $h\in[1,p-1]$, then compute $g=h^{(p-1)/q}$ mod $p$.
If $g\neq1$, then does it mean that $g$ is of order $q$? If yes, then how? Because I couldn't find out the reason.
Reference: Guide to Elliptic Curve Cryptography, D. Hankerson, A. Menezes and S. Vanstone, Algorithm 1.6, page#9.
Note: I have searched in the forum for a similar type of question but couldn't find one.
Yes, you are right. You know that $g^q = 1$ (because $h^{p-1}=1$ by Lagrange's theorem), so that the order of $g$ divides $q$.
As $q$ is prime, the order of $g$ is either $1$ or $q$. Since $g≠1$, it follows that $g$ is of order $q$, as desired!