If you really must use sed, then a possible algorithm would be to keep adding spaces in front of string math so long as there are 18 or fewer preceding characters:
$ sed -e :a -e 's/\(^.\{,18\}\)math/\1 math/; ta' file
how are you math123
good math234
try this math500
If you want to move only the last occurrence of the string, then you can anchor it to the end of the line. For example, given something like
$ cat file
how are you math123
good math234
try this math500
math101 is enough math
then provided there is no trailing whitespace
$ sed -e :a -e 's/^\(.\{,18\}\)\(math[^[:space:]]*\)$/\1 \2/; ta' file
how are you math123
good math234
try this math500
math101 is enough math
If your sed has an extended regular expression mode, you can simplify to
sed -E -e :a -e 's/^(.{,18})(math[^[:space:]]*)$/\1 \2/; ta'