The Twitter comment came amid a spat between Mr Musk and Vern Unsworth, a diver who had claimed the Tesla founder’s offers to help save the children were a “PR stunt”.
Mr Unsworth said he was considering legal action, while some investors in Mr Musk’s company had demanded an apology.
On Wednesday morning, Mr Musk responded to a Twitter user who had shared an article about the dispute, saying: “As this well-written article suggests, my words were spoken in anger after Mr Unsworth said several untruths & suggested I engage in a sexual act with the mini-sub, which had been built as an act of kindness & according to specifications from the dive team leader.
“Nonetheless, his actions against me do not justify my actions against him, and for that I apologise to Mr Unsworth and to the companies I represent as leader. The fault is mine and mine alone.”
Mr Unsworth, a Briton living in Thailand, had experience of the caves where the boys became stuck, and was part of the lengthy and complex rescue operation.
When Mr Musk offered his help, posting videos online demonstrating how “a tiny, kid-size submarine” could be used to save those stranded, Mr Unsworth branded it a “PR stunt” and said the businessman could “stick his submarine where it hurts”.
In screenshots of a now-deleted tweet from Mr Musk’s verified account at the weekend, he said he would make a video of his mini-submarine going into the caves, adding: “Sorry pedo guy, you really did ask for it”.
Responding to the tweet, Mr Unsworth told Australia’s 7 News: “It’s not finished. I believe he has called me a paedophile.”
All 12 boys and their football coach were rescued over the course of three days earlier this month after an operation that lasted more than two weeks and captured global interest.
The group had entered the underground network in Chiang Rai province for exploration on June 23 before it became flooded by monsoon rains.
Their rescue was particularly treacherous because the boys, aged 11 to 16, had to swim through tight spaces despite having no previous diving experience.
Several British elite divers flew to the region to help with the rescue at the request of Thai authorities.