JOHANNESBURG, Dec. 8— Col. Bob Denard was cheered as a hero in the Comoro Islands after he pulled off a bold coup in 1978 that returned Ahmed Abdallah Abderemane to the presidency of the Indian Ocean island nation.

But President Abdallah was assassinated 12 days ago, and now the Comorans are trying to get rid of the aging soldier of fortune and his motley band of European mercenaries. Many of them hold Colonel Denard responsible for the killing of Mr. Abdallah. A 'Golden Handshake'? France and South Africa are also trying to get rid of the colonel, and the two nations this week cut off financial aid to the Federal Islamic Republic of the Comoros, a cluster of islands between Mozambique and Madagascar.

According to one report circulating in Paris and Pretoria, the colonel has demanded nearly $40 million as the price for his departure. Another report says he turned down a similar ''golden handshake'' extended by the two Governments.

''We're looking at a business deal to get rid of him,'' said a diplomat who has watched events unfold in the Comoros. The diplomat said he expected Colonel Denard eventually to quit the islands in return for a less spectacular payoff, asylum in a country like South Africa and a guarantee of immunity from prosecution for his men.

For Colonel Denard, a burly French mercenary who has reached the age of 60 in a profession not known for longevity, the Comoros had become a haven after he spent more than two decades as a hired gun in Africa's coups, rebellions and civil wars.

He has been skittish of the press, and it remains unclear how he first took up arms, although he has worn what look like French paratrooper wings on his khaki tunic. Various reports have said he served in Indochina, Yemen, Chad and Libya. A Full Resume as Mercenary

He came to prominence in 1967, when he led an unsuccessful invasion of Katanga province, now Shaba, in Zaire. A year later, he popped up in Biafra as that region fought to secede from Nigeria.

He was said to have served in Angola in 1975 on behalf of the National Front for the Liberation of Angola, a guerrilla faction that was one of the losers in the civil war that erupted when the Portugese pulled out. He subsequently led an abortive attempt to topple President Mathieu Kerekou in Benin. There have been rumors of links to the United States Central Intelligence Agency and the French secret service. His rendezvous with the Comoros came in 1975, when he helped depose President Abdallah, who had become head of state after France granted independence to three of the four islands. Inhabitants of the fourth island, Mayotte, elected to remain under French rule.

The islands, best known for their vanilla, cloves and other spices, had for centuries put up with foreign invaders, including mercenaries from Madagascar, before France extended its control over the archipelago between 1843 and 1886. The country now has a predominantly Muslim population of about 450,000. A Bizarre Dictatorship

Ali Soilih, the ruler whom Colonel Denard installed in 1975, imposed a bizarre dictatorship blending Maoist ideology with Islamic values on the islands' inhabitants, whom he terrorized with a revolutionary youth brigade of uneducated thugs.

Colonel Denard then went back to Paris and assembled a new force of 30 seasoned French and Belgian mercenaries. In 1978, at the behest of the leader he had ousted, they sailed a battered fishing trawler down from Europe, around the Cape of Good Hope and up to Grande Comore, the largest island, now called Njazidja.

The invasion force, armed with shotguns and hand grenades, landed at night and captured the country in about three hours. President Soilih was shot to death by the mercenaries two weeks later, reportedly when he tried to escape, and President Abdallah was returned to power.

Major Denard, as he then called himself, may have had a personal motive for switching loyalties. ''Denard had never fought for a real winner, and he wanted one last curtain call for a dying profession,'' David Lamb, an American journalist, wrote in his book ''The Africans.''

The Comorans greeted the mercenaries as liberators, although they were denounced by the Organization of African Unity, which initially refused to recognize the new Government. The soldier of fortune reportedly boasted that with the popular support he had, it would take a force of 10,000 Cubans to push him out of the Comoros. Colonel Takes Islamic Name

He gave himself Comoran citizenship, embraced Islam, took the name of Said Moustapha Mouhadjou and married a local woman half his age.

Over the last decade, he reportedly has acquired profitable real estate and business holdings in the islands, including an interest in a resort built by the South African Sun Hotels chain.

Colonel Denard, ostensibly only a presidential adviser, took control of the 500-man Presidential Guard that was created to protect Mr. Abdallah. Early this week it was disclosed that since 1984 South Africa had subsidized the Presidential Guard with about $3 million a year, apparently to insure that the Comoros would not turn against Pretoria.