In my opinion it is not really relevant whether one requires $f$ to be surjective or not. As José Carlos Santos has pointed out in his answer, if $f$ is not surjective, then some $A \in \mathcal A$ remain unindexed which we probably do not want.
What does Mukres do with $f$? He writes $A_\alpha$ for $f(\alpha)$ and defines
the union $\bigcup_{\alpha \in J} A_\alpha$
the intersection $\bigcap_{\alpha \in J} A_\alpha$
the Cartesian product $\prod_{\alpha \in J} A_\alpha$
This can be done for any function $f : J \to \mathcal A$, i.e. for any indexed collection of sets $(A_\alpha)_{\alpha \in J}$ in $\mathcal A$.
But why do we need index functions at all? Why doesn't it suffice to work with collections of sets $\mathcal A$? In other words, why don't we simply index $\mathcal A$ by itself (i.e. take $J = \mathcal A$ and $f = id$)? Yes, we can do that, and in this case we get for example
For an arbitray function $f : J \to \mathcal A$ we get
and this shows that the surjectivity of $f$ is a useful property.
Note that we can always replace $\mathcal A$ by the subset $\mathcal A' = f(J) \subset \mathcal A$ and thereby get a surjective index function $f' : J \stackrel{f}{\to} \mathcal A'$ which is essentially the same as $f$.
The main point is that in an indexed collection sets may occur repeatedly (which is impossible in $\mathcal A$ itself). For example, if $\mathcal A =\{A\}$ has only one member, we can nevertheless form arbitrary indexed collections $(A_\alpha)_{\alpha \in J}$ with $A_\alpha = A$ and consider the Cartesian product $\prod_{\alpha \in J} A_\alpha$. This does not agree with $\prod_{A \in \mathcal A} A$ (which is just $A$).
Let us finally observe that in practical applications it may even be even inconvenient to require index functions to be surjective. For example, in a topological space $X$ one often assigns to each point $x \in X$ an open neigborhood $U_x$ of $x$ in $X$. This may be regarded as a function $f : X \to \mathfrak T_X, f(x) = U_x$, where $\mathfrak T_X$ is the topology of $X$. In general such functions will not be surjective and we do not explictly know what $f(X)$ looks like. Nevertheless I tend to accept $f$ as index function.