Video filmed by Lance Karlson shows the creature race through shallow water towards the pair at Geographe Bay.
As the octopus approaches it attempts to leap out of the sea and whips its tentacles towards Mr Karlson, who managed to capture the incident on his camera.
Mr Karlson said he noticed the octopus after it had similarly tried to attack a seagull a short time before.
He says he went swimming soon after and found the octopus resting among a bed of shell.
At this point, Mr Karlson said, the octopus attacked him, hitting his neck and arms with its tentacles.
He told 9News.com.au: "My goggles were too fogged to see what had happened and I swam back to shore in pain.
"The imprints of the tentacles quickly formed raised marks across my skin."
Mr Karlson, an author and former lifeguard, said his wife rushed to help him after the attack.
"There was some stinging, but after being a lifesaver for some years I've been stung by bluebottles and it was not anything like that," he explained.
"It was more the pain from the physical strike of the octopus."
Mr Karlson has since shared the video on his social media, where a number of octopus researchers have remarked how unusual it is to see this kind of behaviour.
Octopuses, part of the cephalopod family, are considered one of the most intelligent invertebrates and rarely attack humans.
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies