You need something like the following
if (input$td == 'lm'){
p1 <- p1 + geom_smooth(<your options here>) + geom_text(<your options here)
} else {
p1 <- p1 + geom_text(<your options here)
}
That is basic ggplot2 syntax. You may want to read @hadley's book (https://github.com/hadley/ggplot2-book)