Rotation of rotated element
The object that you want to rotate should first be parented to an 'empty'.


In Object Mode, hit Shift-A, then select 'Empty', then 'Circle'.
Clear all rotations on your gear object (set all to zero)
Move your object to the center of the Circle Empty.
Select your rotating gear object FIRST, then hold shift and select the Empty, then hit 'Ctrl+P', then 'Object'


You can now place your Empty (along with the gear) anywhere you want, at any angle. When you tell the gear object to rotate it will rotate around the X,Y,Z orientation local to the empty.