Up until a few weeks ago, I had a beautiful and 11 inch red Oscar, unfortunately she died. Anyway, I recall her doing exactly what you describe yours doing a few years ago (nothing to do with her demise, before you worry) it was almost as if she was having some kind of fit. Anyway, like I said this was probably three years ago and she lived for a long time after.. why they do it is a mystery. They could have something stuck in their mouth which they are trying to dislodge I suppose. Maybe even some irritation somewhere on the body makes them do it.
If the fish only does it occasionally and is okay the rest of the time, I shouldn't concern yourself too much