Question: how do you know when iphone battery needs replacing?
Answer: Go to Settings > Battery.
Tap on Battery Health.
You will see what the 'maximum capacity' of you battery is - this is a measure of your battery capacity relative to when the battery was new. ... 
Below that is an indication of the battery's 'Peak Performance Capacity'.