Let y be a point in three dimensional space and let
To see this is so, take an arbitrary V for which the divergence theorem holds. Then the time rate of change of the mass in V is
where the derivative was taken under the integral sign with respect to t. (This is a physical derivation and therefore, it is not necessary to fuss with the hard mathematics related to the change of limit operations. You should expect this to be true under fairly general conditions because the integral is a sort of sum and the derivative of a sum is the sum of the derivatives.) Therefore, the rate of change of mass
Since this holds for every sample volume V it must be the case that the equation of continuity holds. Again, there are interesting mathematical questions here which can be explored but since it is a physical derivation, it is not necessary to dwell too much on them. If all the functions involved are continuous, it is certainly true but it is true under far more general conditions than that.
Also note this equation applies to many situations and f might depend on more than just y and t. In particular, f might depend also on temperature and the density ρ. This would be the case for example if you were considering the mass of some chemical and f represented a chemical reaction. Mass balance is a general sort of equation valid in many contexts.