I'm making this to add more clarity from the previous solution. So to get this ending you need to get enough humanity throughout the game by basically telling lies as much as possible and you can also listen to the records you get throughout the game.
The cut off point to get this ending is at Sophia on Ascension bridge, once you go through the door to sophia you HAVE to choose give her peace and then your hair should change to white if you have enough humanity to get the ending.
You then need to refuse to give Gepetto your heart after speaking to him and kill the nameless puppet to get the achievement.
About knowing if you have enough humanity, there are 4 levels to your humanity level each with a different message:
Level 1: Your Springs are Reacting
Level 2: The Ergo is Whispering
Level 3: You Feel Warmth
Level 4: Your Heart is Pounding
Level 4 is what you want so if you see the heart is pounding message after a lie or listening to a record then you are on track to get it and should be fine to give peace to Sophia at that point.
A list of all lie locations can be found here also -
https://liesofp.wiki.fextralife.com/EndingsHope this helps, I had to try this twice as I wasn't aware of the humanity levels