How to find the smallest $n$ such that $n^a\equiv 1 \pmod p$

The Tonelli-Shanks and Cipolla algorithms for square-roots can easily be generalized to compute d'th roots in finite fields, e.g. see Adleman; Manders; Miller: On taking roots in finite fields, and Bach; Shallit: Algorithmic number theory, section 7.3. See also this answer.