It estimated TikTok allowed up to 1.4 million UK children aged under 13 to use the platform in 2020.
The video-sharing site used the data of children of this age without parental consent, according to an investigation by the Information Commissioner's Office (ICO).
TikTok said it had "invested heavily" to stop under-13s accessing the site.
The ICO said many were able to access the site despite TikTok setting 13 as the minimum age to create an account.
It said that children's data may have been used to track and profile them, and potentially present them with harmful or inappropriate content.
Information commissioner John Edwards said: "There are laws in place to make sure our children are as safe in the digital world as they are in the physical world. TikTok did not abide by those laws.
"As a consequence, an estimated one million under-13s were inappropriately granted access to the platform, with TikTok collecting and using their personal data.
"TikTok should have known better. TikTok should have done better. Our £12.7m fine reflects the serious impact their failures may have had."
Later, he told BBC News TikTok had "taken no steps" to obtain parental consent.
"When you sign up you can be targeted for advertising, you can be profiled, your data contributes to an algorithm which feeds content," he said.
"If you've been looking at content which is not appropriate for your age, that can get more and more extreme.
"It can be quite harmful for people who are not old enough to fully appreciate the implications and to make appropriate choices."
It is one of the largest fines the ICO has issued.
A TikTok spokesperson told the BBC "our 40,000-strong safety team works around the clock to help keep the platform safe for our community".
"While we disagree with the ICO's decision, which relates to May 2018 - July 2020, we are pleased that the fine announced today has been reduced to under half the amount proposed last year. We will continue to review the decision and are considering next steps."
The watchdog had previously issued TikTok with a "notice of intent" - a precursor to handing down a potential fine - at the time saying TikTok could face a £27m fine for these breaches.
Prof Sonia Livingstone, who researches children's digital rights and experiences at the London School of Economics and Political Science, told the BBC it was "great the ICO is taking action", but feared the fine amount could be "shrugged off as the cost of doing business"."Let's hope TikTok reviews its practices thoroughly and make sure that it respects children's privacy and safety proactively in the future," she said.
Louise Devine has told the BBC she allows her 10-year-old son to use TikTok, though she monitors his usage.
"I know exactly what he's posting and I do monitor who he's talking to. Obviously, I can't monitor what he sees," she said.
"I don't think I would stop him from using it because all his friends are using it and I think that would be quite unfair, however, I do think that if I could have a way of monitoring what he sees that would be better for me."
TikTok is allowed to appeal against the scale of the fine and has 28 days to make representations. If successful, the ICO could reduce the final amount.
The regulator has a maximum of 16 weeks, from issuing the notice of a proposed fine to delivering its final verdict.
Fines received by the ICO go back to the Treasury.
But there may be further concerns for TikTok as the UK Online Safety Bill, due to be passed in the coming months, requires strict age verification processes by social networks.
It has been suggested firms will be fined for breaches - but a £12.7m fine is a small amount compared to the $80bn (£64bn) revenue reported to have been made by TikTok's parent company ByteDance, a Chinese tech company, in 2022.
And it comes as the platform is already under global scrutiny over security concerns.
Many Western countries are taking measures against TikTok over fears users' data will be shared with the Chinese government.
The app has been banned on government devices in Canada, Belgium, Denmark, New Zealand, Taiwan, the UK, the US and for anyone working at the European Commission.
TikTok boss Shou Zi Chew was grilled in Congress over its safety and tried to reassure lawmakers that users' data was secure.
The BBC has advised staff to delete TikTok from work phones.