The solution is to make full use of the fact that the balance can tell you two pans are equal. Whenever the two pans are of equal weight, you can conclude that the defective ball is not in either pan.
For the first weighing, pick any three balls and weigh them against any other three balls. This has two possible outcomes.
One is that the balance finds the two pans equal. In that case, the defective ball must be one of the two you didn't weigh. For the next and last weighing, just compare the two still-untested balls. The heavier one has to be the defective ball.
The other possible outcome of the first weighing is that the balance finds one of the two pans heavier. The defective ball must be in the heavier pan. For the final weighing, pick any two of the balls in the heavier pan and compare them. If one is heavier, it's the defective ball. If both are equal, the defective ball has to be the third ball that you didn't weigh this time.