I'm gonna guess that it's the freewheel. Some of them have enough play to knock a bit. It is always intermittent. Next time it happens, try spinning the cranks backward one revolution - see it it stops.
This is a common problem on the SS BMX type freewheels.
-G