Customizations for interactive shells go into ~/.bashrc. Things that you want to run when you log in go into ~/.profile (or ~/.bash_profile, but it's often not loaded when logging in graphically).
Put this function definition in ~/.bashrc.
Since bash doesn't load .bashrc when it's a login shell, force it to do so: write a ~/.bash_profile containing
. ~/.profile
case $- in *i*) . ~/.bashrc;; esac
i.e. load ~/.profile, and also load ~/.bashrc if the shell is interactive.
See Alternative to .bashrcAlternative to .bashrc and the posts linked there.