A sort of inverse question in topology
Solution 1:
There need not be any such topologies in general. You've noted, for example, that all constant functions are continuous, so if your sub-collection of functions does not have all constant functions as elements, then we're out of luck in topologizing $X$ and $Y$ in the desired fashion.
There may be other necessary conditions on your subcollection to determine such topologies on $X$ and $Y$. I'll think on it.
Added: It occurred to me (very belatedly, of course) that this answer to a prior question of my own gives a very important necessary condition for such a topology to exist, if we are considering self-maps (meaning $X$ and $Y$ are the same topological space). Namely, the sub-collection of functions in question must be closed under finite compositions, i.e.: given elements $f,g$ of the sub-collection, $f\circ g$ is also an.element.
Solution 2:
Assume $Y$ only consists of two points $Y=\{a,b\}$. There are effectively three choices for a topology on $Y$. Let us assume we don't have the indiscrete and not the discrete topology, so wlog the open sets are precisely $Y$, $\emptyset$ and $\{a\}$. Now every $g_i$ must be continuous, in other words $g_i^{-1}(a)$ has to be open. So the collection $\{g_i\}$ is the same as a subbasis of $X$. Conversely every open set $O$ in the topology of $X$ gives you a continuous function $g:X\to Y$ with $g(O)=\{a\}$ and $g(X-O)=\{b\}$.
So in this case you are asking if any subbasis of a topology is already a topology. I guess if $Y$ is bigger the situation will get worse.