Make some inputs inside functions instead of main
You are using classes wrong. With your class, you can never have two friend books, because each instance uses the classes mutable listOfFriends. (N.B.: A dictionary called listOf... is not very helpful).

Instead, have one FriendBook object, and let its methods take arguments:

class FriendBook:

    def __init__(self):
        self.friends = set()

    def add(self, firstname, lastname):
        self.friends.add((firstname, lastname))

    def remove(self, firstname, lastname):
        self.friends.remove((firstname, lastname))

    def __str__(self):
        return '\n'.join("{} {}".format(*name) for name in self.friends)


A few notes:


The friends are a set now (this assumes that no two friends share the same first and last name, already a better assumption than yours, which assumed that every friend had a unique last name). You could also make it a list, you would just have to change self.friends.add to self.friends.append.
The magic function __str__ allows simply calling print(fb), where fb is an instance of FriendBook, to print the full list of friends.
I made the names a bit easier. Note that Python has an official style-guide, PEP8, which recommends using PascalCase for classes and snake_case everywhere else.


For your main question, yes you can put these in a function:

def ask_name():
    first_name = input("Enter firstname\n")
    last_name = input("Enter lastname\n")
    return first_name, last_name


I would also slightly rewrite your main function, like this:

if __name__ == "__main__":
    fb = FriendBook()
    while True:
        print("1. Add Friend\n2. Show Friends\n3. Remove Friend\n9. Quit\n")
        try:
            option = int(input())
        except ValueError:
            print("Only integers allowed")
            continue
        if option == 1:
            fb.add(*ask_name())
        elif option == 2:
            print(fb)
        elif option == 3:
            fb.remove(*ask_name())
        elif option == 9:
            break
        else:
            print("Not a valid option")


Notes:


I wrapped it all in a if __name__ == "__main__" guard to allow importing this class from another script.
I use the defined function to ask for the names and use tuple unpacking to pass it to the methods.
I limited the scope of the try...except clause and made it more specific. Your current except covered everything, even, for example, the user pressing Ctrl+C. You should almost always avoid doing this.