A dog in Turkey is being hailed as a hero after stopping a baby from crawling into the ocean. Credit: DHA, Source: Live Leak.

A dog is being hailed as a hero after its owner went to see what it was scratching at in the dirt by a field in northern Thailand and found the leg of a baby buried alive poking out.

The baby boy had been buried alive by his teenage mother soon after she gave birth to hide the fact she had been pregnant.

The dog, which has only three working legs and is called Ping Pong, was scratching in the dirt by a cassava plantation last Wednesday in Ban Nong Kham village in Thailand’s Nakhon Ratchasima province.

Ping Pong’s owner heard his black mutt barking and went to investigate, the Bangkok Post reported.

Usa Nisaikha, a 41-year-old farmer, saw the dog digging up a dirt pile and when he got closer he saw a leg protruding from the soil.

The baby was dug up and taken to a hospital where doctors said the 2.3kg infant hadn’t suffered any serious injuries.

Police said the baby survived because he was buried shallowly.

Police arrested the boy’s 15-year-old mother and charged her with child abandonment and attempted murder.

The teenager is undergoing a mental health assessment.

“She regrets what she did and said she acted on impulse without thinking it through,” Lieutenant Colonel Panuwat Puttakam told the Bangkok Post.

The girl confessed she delivered her baby alone and then buried him because she feared her parents who did not know she had been pregnant.

Mr Usa, who got six-year-old Ping Pong as a puppy, praised his dog.

“Ping Pong was hit by a car, so he’s disabled,” Mr Usa told Khaosod English.

“But I kept him because he’s so loyal and obedient, and always helps me out when I go into the fields to tend to my cattle.

“He’s loved by the entire village. It’s amazing he found the baby.”

candace.sutton@news.com.au