There are a few attributes that I know of that enable your pet to cast a spell on its own.
Spritely- your pet casts a "Sprite" spell Unicorn- pretty self-explanatory there
Those are the two best spell-related pet abilities in my opinion. There are also pet abilities that allow them to cast blades or shields (the type of which depends on the school of the pet in question)
To increase the chances of getting a pet with those attributes, find someone whose pet has them and hatch one of your pets with them. The offspring will then have an increased chance of getting the coveted ability.
Pet attributes increases the max stat for a pet. May cast talents are specific ones your pet gets. Example: Spritely, Batusi, Unicorn, Balanceblade, ETC. Hatch for those talents.