You are looking at borer larvae that tend to attack injured or stressed trees. Insecticides are of no use against larvae under the bark. Remove and dispose of all dead or dying limbs. If your entire tree is dying, remove it so that other plantings are not affected. A Certified Arborist can evaluate the extent of the problem and recommend the appropriate action.
Prevention is the best management.
Keep trees vigorous and guard them from injury and sunburn. I have a Hass avocado tree but there is no fruit. It has produced well in the past. The Hass avocado can tolerate freezing temperatures but the fruit and flowers may not. Chilly weather during bloom may limit fruit set.