Let TOP be a category of topological spaces and B be an object of TOP. Is there a notion of function space in the comma category TOP/B.
Yes, there is a long history on that subject. It is actually quite subtle point-set topology. The best of the original sources is a series of papers by Peter Booth. A more recent treatment with full details and references is in Section 1.3 of the book "Parametrized homotopy theory" by Johann Sigurdsson and myself. It is available at http://www.math.uchicago.edu/~may/EXTHEORY/MaySig.pdf. [Added] I'll say something about the choice of "a" category $Top$. As usual, we insist that all spaces in sight are $k$-spaces (compactly generated, but with no separation property). We insist that the base space $B$ be weak Hausdorff. We cannot insist that the function space $Map_B(X,Y)$ also be weak Hausdorff, even when the given spaces $X$ and $Y$ over $B$ are weak Hausdorff. Indeed, when that holds, the map $X\longrightarrow B$ is open if and only if $Map_B(X,Y)$ is weak Hausdorff for all $Y\longrightarrow B$, by a result of Gaunce Lewis.