Learning office politics is part of any job. Wise Bread  shares a few hacks to follow when it comes to working with your boss.
When I started my first "real job," I didn't realize how many situations I'd find myself in that were utterly different from most of what I'd encountered before. On top of learning the tasks specific to the job, I had to navigate office politics, figure out what it meant to be "professional," and make decisions about these things on the fly with only my intuition to guide me. I made a few mistakes while I figured it out, but eventually I learned to survive, thrive, and make my boss love me. While I'm still no expert, what I offer here are solutions to common problems that have worked for me.
RELATED: How to Answer 23 of the Most Common Interview Questions 
Note: These suggestions will be particularly relevant to entry-level positions, but could be useful at other times, as well.
Make Your Boss Love You When You've Finished a Project
Let him know you're thinking about the future. Either ask him, "So, what's next?" or let him know you'll be needing some time to get things together before he approaches you with the next project. Something like, "I'm getting ready for the next project. Could we talk about it in an hour/this afternoon/tomorrow/next week after I tie up some loose ends? I've been focusing on getting this done but want to make sure I haven't let anything fall through the cracks." Both approaches let him know that you're focused on what is best for the company, and the second also makes you look responsible while also taking a short break.
Make Your Boss Love You When She's Pointing Out Little Mistakes
Remember that pointing out your small mistakes is part of her job, and it may be as distasteful to her as it is to you. If the criticism is particularly difficult for you to hear, remember to breathe before you say anything. A deep breath or so, when done surrepitiously, can give you the strength to respond calmly. Then, if it's appropriate, defend yourself. If her criticism is just, nod as she speaks. Tell her, "Thank you for showing me how you would prefer this to be done/how this should be done/whatever." If she persists, or is talking to you about something for the Nth time, say, "This seems to be something that you want me to work on/I should work on. Are there any resources available to help me improve?" Whether you need to be on time, make the webpage load faster, or something else, it's hard for a boss to fault an employee who wants to change. If she points you in a direction, follow through!
Make Your Boss Love You When You're Swamped and He Wants You to Do More
Be honest about what you can do. Most supervisors appreciate hearing when their people are overworked and stressed. If he likes up front, honest people, say, "You know, I'd be happy to take that on, but realistically I won't be able to get to it until I finish with X, Y, and Z. Will that work for you?" He may take it to someone else, or he may give it to you, but either way he knows what he's looking at. If he's going to lay it on you no matter what you say, try, "I'll take that on. Right now, I'm working on P, D, and Q. Where does this fall in priority relative to those?" With this, he knows where he stands and what you have on your plate, and he can determine when you get to it.
Make Your Boss Love You When You've Made a Big Mistake
If you can't fix it before she would find out, be the first to let her know. Swallow the butterflies and make your weak knees walk to her office (or write that email). Most of the time she's going to find out anyway, so you're only prolonging the agony and creating a ton of anxiety for yourself if you don't tell her. Your poise and honesty will also make an impression, even if she's upset and there are consequences. At the very least, she'll have a positive sense of your integrity for any future recommendations. And you might save your job.
Make Your Boss Love You When You're Interviewing For a New Job
In a few companies, interviewing for a new job is considered tantamount to treason. If you work for one of those companies, keep your search under the table, but don't lie if you're asked directly. You might be asked to leave, but they won't be able to fault your integrity in a recommendation. But if you work for most companies (or, at least, most of the ones I've experienced/heard about), just be honest. If you're valuable where you are, you would be surprised how many times your boss will do all she can to get you a counter-offer. If she can't or if she has some other motivation to not re-hire you, she will appreciate not being blind-sided when you turn in your notice.
Check out these smart tips from Wise Bread:
10 Things You Can Do Right Now to Become More Hirable 
Why Women Don't Negotiate 
Create Your Own Raise