The short answer is that in your example there's no reason to assume that the controller was asking the pilot to maintain visual separation. If the controller had wanted the pilot to do that, they would have asked if the pilot had traffic in sight and the pilot would be expected to answer the question.
The ATC orders have an entire section on visual separation (section 7-2-1) with lots of details. There are two types: ATC-applied and pilot-applied, depending on who's actually responsible for maintaining the separation. I think you're asking about pilot-applied separation, and there's really nothing in the dialog you quoted that suggests the controller intended the pilot to maintain their own separation. In fact, it's possible that the controller was maintaining visual separation themselves based on seeing both aircraft, and that doesn't require the pilot to have the other aircraft in sight.
If ATC assigns pilot-applied separation, they need to hear two things from the pilot: they have the traffic in sight, and they will maintain visual separation. See 7-2-1(a)(2)(c):
If the pilot reports the traffic in sight and will maintain visual
separation from it (the pilot must state both), the controller may
“approve” the operation
The Orders have an example and it's laid out as a three-step process: first the controller tells the pilot where the other aircraft is, then they ask the pilot to confirm traffic in sight, and finally if the answer is positive they ask the pilot to maintain visual separation. Since ATC is asking a question, the pilot has to answer one way or another, whether that's with "traffic in sight" or "negative contact".
Coming back to the example you gave, the controller simply told the pilot that they were number 2 behind other traffic. The controller didn't ask if the pilot had traffic in sight and while the pilot might volunteer that information, the controller didn't need it at that point in time (they might need it later if the aircraft are getting too close, or something else changes).
Long story short, if ATC needs to know if you have the traffic in sight then they'll ask you.