The photo had been posted on Twitter but has since been taken down.
It shows the star inches away from the edge of the skyscraper, where he lives on the 34th floor, the lights of London behind him.
The 20-year-old tweeted, "You may have seen a photo of me today taken on top of a building. I regret being there and having a photo taken.
"It was a stupid and irresponsible thing to do. I am sorry, and do not endorse any fans trying to repeat this, as it is extremely dangerous."
The picture is believed to have been taken over the weekend, when Liam entertained three friends visiting from his hometown of Wolverhampton.
Pictures of their time together, including a night out at Funky Buddha, were posted on their respective Twitter pages.
Unfortunately for Liam, other photos taken by his friends have led fans to deduce his address - and many have started camping out outside his home.
"I know my friends have tweeted a lot of pictures of my house the past few days but can people please stop coming and waiting outside," Liam tweeted on Tuesday.
"I'd just like to be able to walk outside as everyone does and enjoy time with my friends, not feel bad for not wanting to take a picture.
"Sorry if I've been rude to anyone but I've come to realise if I take one picture more people keep coming everyday xxx hope everyone's good."