My rule of thumb: Be courteous, and always err on the side of formality. “Yo” and “Hey” are inappropriate; you and your instructor are not peers.
If your instructor has indicated on the course syllabus that s/he has PhD, then you should address him or her as Dr or Professor. If you don’t know whether s/he has a doctorate, go with “Professor” since that is the person’s role. Whatever you do, always use the same level of formality regardless of the person’s gender. I’m Dr Lovell or Professor Lovell; I don’t answer to Mrs Lovell. Mrs Lovell is my mother. I get especially cranky when I hear you call my male colleague Doctor or Professor So-and-so and then turn around and call me Miss, Ms or Mrs Lovell.
If your instructor says to you in a one-on-one conversation, “Call me Katie,” then by all means, go ahead. But try not to put other students in an awkward position; Katie may know you because you’ve taken three courses from her and she can put your name to your face, but other students may not be in the same situation and might feel uncomfortable with that degree of familiarity. Your peers will probably think you are showing off if Katie hasn’t invited everyone in the class to use her first name.
Your TA likely will not have a doctorate. Some will have Bachelors or Masters degrees, but some will be senior level undergraduates (this practice varies considerably). The formal form of address would be “Ms” or “Mr”, at least in the first instance, but many TAs prefer to be called by their first name and should tell you this at the first lab or seminar. If your TA happens to be another undergraduate student in your program then Ms or Mr would be unnecessary and probably embarrassing to all concerned.
If you’re going to your instructor’s office hours it helps if you identify yourself when you arrive at their door: “Hi Professor Lovell, I’m Emily Piper and I’m in your introductory anthropology class. I have a question about something you said in lecture this morning.”
Note that specific suggestions are designed for colleges and universities in North America. There is a great deal of diversity among countries, colleges, and departments as to the level of formality that is required. Unfortunately, rarely will anyone actually tell you what the unwritten rules are, and you may have to figure out the system just by watching other professor-student interactions. In any event, you can’t go wrong if you are unfailingly polite.