My 2000 Nissan Altima has some rust on the metal brake lines. Is there a way to tell when they should be replaced?
Unfortunately you can't.
Brake lines have double the strength than they need. Rust degrades that strength. The problem is that at 50% strength they still stop the car without a problem. Now when they degrade below this a good panic stop can burst a line. The line won't show any visual signs of being ready to burst. If your lucky (sort of) the line will start weeping so that it's visually leaking brake fluid but at this point the line is down to less than 10% integrity and will burst with only moderate brake effort.
Judging what state the lines are in is impossible. The real decision is whether you want to replace the lines before they burst.
In the UK, any significant corrosion will be picked up on the annual safety inspection (MOT) and the tester will advise or require replacement.
They use a visual only check so this is rather subjective but the criteria that they apply is, in their opinion, has the corrosion made the sidewalls of the pipework any thinner that it would have originally been.
Given that the cost of replacement is very low and the damage that can result if one of these lines fails in operation, I'd personally air on the side of caution and replace them for, if anything, my own piece of mind.