You can either add a second s command:
sed -n 's:.*<first_name>\(.*\)</first_name>.*:\1:p;s:.*<last_name>\(.*\)</last_name>.*:\1:p' 'test.xml' > name.txt
or use an extended regular expression:
sed -En 's:.*<(first|last)_name>(.*)</\1_name>.*:\2:p' 'test.xml' > name.txt
Update: Request to output both names in the same line
To have the output on the same line, you can simply pipe it through another script to join lines with a whitespace:
sed -En 's:.*<(first|last)_name>(.*)</\1_name>.*:\2:p' test.xml | sed 'H;1h;$!d;g;s/\n/ /g' > name.txt
The H,1h;$1d;g is used to join all lines in the pattern space (H appends all lines to the hold space, 1h overwrites the hold space for the first line to avoid a preceding newline, $!d stops processing for all but the the last line and g move the hold space contents to the pattern space), then s/\n/ /g replaces all newlines with white spaces; in your case you could drop the g if you are sure there will be always only two lines.
On linux, you probably have GNU sed and could do sed -z 's/\n/ /g' for the same result.
More elegantly, and capable of dealing with multiple name pairs in one file, you could also do something like
sed -e '/.*<first_name>\(.*\)<\/first_name>.*/{s//\1/;h;}' -e '/.*<last_name>\(.*\)<\/last_name>.*/!d;s//\1/;H;g;s/\n/ /' 'test.xml' > name.txt