How does an electronic shocker works?
Yes, the transistor works as an oscillator.

Let see if I can explain the working. The transistor starts by conducting, because it gets base current via de resistor and the small section of the secondary coil. For some time the current through the primary coid will increase. When its stops increasing, the sudden drop in the change of current is transformed to the (small) secondary coil and causes the transistor to switch off. This effect is only temporary, and when it is over the cycle starts again.