Your function is already vectorised, so you don't need to change a thing,
add_lines <- function(yx){
annotate("segment", x=-Inf, xend=Inf, y=yx, yend=yx,size=1, colour="white")
}
j + add_lines(c(8,10,20))
Conceptually, however, if you wanted to add lines one by one, you could simply use a list:
add_oneline <- function(yx){
annotate("segment", x=-Inf, xend=Inf, y=yx, yend=yx,size=1, colour="white")
}
lines <- lapply(c(8,10,20), add_oneline)
j + lines
but that's less efficient and more convoluted than the first option.