Your solution looks perfectly fine to me, there are some things I think you could expand on a touch (which I'll get into later) but it's pretty much exactly how I would go about doing it.
As far as convincing yourself that your proof is correct, I think there are two main components to that. The first is the high-level, conceptual logic of your proof: you need to show that the order of $|g^{-1}xg|$ is equal to $|x|,$ which by the definition of the order of an element is equivalent to the statement that $|x|$ is the smallest number $n$ such that $(g^{-1}xg)^n = 1.$ Assuming all of the steps are done correctly, your proof shows that $|x|$ always meets this requirement, and that there can be no lower integer which meets the requirement, which is enough for our goal, so the major structure of your proof is very sensible.
The second component is the lower-level details of your proof, which involves the way that each of your subgoals are proven. In order to ensure this part is correct, I would look very carefully at each step that's taken and be explicit in terms of how it can be justified. These reasonings are sometimes trivial and not worth mentioning in the presentation, but it can still be worth it to look through them.
There are two main spots where I think your solution is just a touch hand-wavey which I would look into when verifying it. The first is your use of the result $(g^{-1}xg)^p = g^{-1}x^pg$ which is common to both subgoals: this is absolutely correct, and makes sense intuitively, but to ensure that it goes through rigorously I might consider including this as a lemma and prove it by induction: the $p = 0$ and $1$ cases are trivial, and the inductive step is very simple to prove by the basic properties of our group.
The second spot which catches my eye is the last line in your manipulation for the second subgoal, where I think it could help to note that the exact step we're taking on both sides is to left-multiply by $g$ and right-multiply by $g^{-1}.$ You probably already knew this from your working out, but I think being explicit about the exact step helps assure that the step is correct.
Do you think you find this kind of framework helpful for verification?