Yeah but you have to draw a line here.
The line is drawn in 14 CFR 91.3. The pilot in command thought he was in danger of a collision, and took evasive action per 91.3(b).
You just can't have pilots deviating around when applicable seperation already exists.
According to the OP, he was not informed that separation already existed. I've noticed that the controllers in my area are consistent about saying that traffic is restricted above or below, as the case may be, but from the OP's description of events, that may have been missing in this situation.
That deviation can make the situation even worse.
It does sound like the evasive action he took made things worse instead of better, but we can't assume that pilot-initiated evasive action will always make things worse. I don't think it's a wise idea to discourage pilots from responding to dangers that they see out the window. I mentioned that if there was time, the appropriate thing to do was to query the controller, but if there wasn't, then the priority has to be "aviate, navigate, communicate," in that order.
If this was a wake turbulence deal then I could understand. Judging by the OP's description, ATC had the situation under control, his inexperience lead him to take a course of action that wasn't necessary. If you fly VFR around Class B & C on a regular basis, aircraft passing with 500 ft vertical is the norm.
Since one of the pilots thought there was danger of a collision, it sounds like ATC did not have the situation sufficiently under control.