What counts as an "assist"?

A kill assist is awarded to a player dealing a fair amount of damage to an enemy before another team member finishes the enemy off. In the case of the situation you mentioned above, it is probable too much time passed between your damage and the pyro's. The kill assist mainly applies to situations of multiple teammates engaging an enemy at the same time, so the timer to get an assist is very short.