Octillery will probably have speed boosts by that time as well. So that means it can just sub before he d punches. Plus with massive defense boosts, confusion won't be much of a problem unless it also has massive attack boosts. You would be better off toxicing it.
The only case where Dynamic Punch won't break through immediately is if Octillery gets 2 Def+ boosts in a row as Machamp switches in. In order to beat Machamp, Octillery would need to get 2 Def+ boosts immediately and a Speed boost somewhere in the next 8 turns, which would only happen 1 out of 70 switch ins. Confusion is a problem not because of the damage from attacking itself, but because it won't always be able to get a Sub up for the next attack.
Why should luck affect it so much though? I know hax is inevitable, but it seems that if the only way to beat it is to "spam a move until a crit happens" then it doesn't make sense to keep it around. I can spam any move until a crit happens, that doesn't mean I have more skill or that I played better.
But it does mean that you won't lose just because the opponent used a certain pokemon. Anyhow, it's far from the only way to beat it. It's just that you can also beat it with a pokemon that's very common anyway.