[LAWS]Law 2.6: Spare balls may be available during a match, but a team must not gain or attempt to gain an unfair advantage by using them or changing them[/LAWS]
Apart from this, I'm not aware of any regulation concerning having two balls on the pitch - unlike in soccer, where it is an automatic whistle with a dropped ball restart. However, I think it clear that the arrival of the second ball - kicked in the direction of play by the attacking winger - distracted the defence. That is why the ref awarded the scrum restart (restart after any other stoppage - Law 20.4(d)), and why there was no penalty against the defender. First offence and all that.
IMO, the ref dealt with it correctly. Stern word to the person who sought to draw the 2nd ball to the ref's attention by throwing it into the melee. I agree with thepercy that it was a cock-up to allow the quick tap with the new ball - Law 2.6 again. Also tha the ref would ahve been well advised to ensure that the 1st ball was off the field before allowing even a normal PK restart.