You wouldn't believe how often this question gets asked! It's one of the commonest English questions on italki.
Basically, if you know the gender of an animal, you can use the gendered subject pronouns 'he' or 'she', the object pronouns 'him' or 'her', and the possessive pronouns 'his' or 'her'.
People almost always refer to their domestic pets as 'he' or 'she'. It would seem very cold and unfriendly to call your pet dog or cat 'it'. You should also use 'he' or 'she' for your neighbours' and friends' pets unless you want to risk upsetting these people. When you take a pet to the vet, the vet will always call the animal 'he' or 'she'. Riders refer to their horses as 'he' or 'she', and a farmer may well call a favourite cow 'she', for example.
It all depends on how you feel about the animal. For example, you'd call your own cute fluffy kitten a 'he' or a 'she', while you might call an ugly smelly old cat in the street 'it'. As you can see, this isn't a question of grammar - it's a question of your attitude towards the animal.