I would take an underwater navigation course to really learn how it's done. Otherwise (or until then), I think ScubaJenny's answer includes the basic drill - you find your way back to the boat by never losing track of where you are in relation to your starting point.jstuart1:I have a jacket style BC and keep it clipped to the bottom D-ring. Mine rolls up tight and is held that way by a velcro strap. Yep it's big and orange but it doesn't flop around and I know it's always there. :11: Only thing I don't like though is that it's hard to inflate. That's why I'd like to find one to inflate with the LP hose.
You can use a compass and keep track of your headings and times, but until you have a lot of experience, you will probably find that this only works if you keep it simple enough so that you can easily visualize your path out and reverse it. In other words, swim north into the current, take a right turn to the east for a few minutes, back to north, and then turn around and reverse the course back to the boat. If you introduce twelve changes in direction with, against, or across a current, your ability to turn around and reverse that course with just your compass and watch is going to be pretty small.
So as you introduce complexity into your course, you will also want to rely on visual cues from large structures (e.g., a reef or wall or the slope of the bottom) - depending on visibility and your ability to distinguish one place from another - to complement the knowledge gained from your compass. Somebody else made the good suggestion to look back every once in a while, to see what it looks like going the other direction (good advice under water and in the woods or desert, too), because that is what you will actually be looking for on the return trip.
At a beginning level you should know that you left the anchor line heading in a particular direction (which should ordinarily be into the current, if there is one).
You should know whether you kept to that direction for some period of time (or air consumption or kick cycles or whatever you want to measure), or whether your course varied from that direction and, if it did, generally which way and how much. You should be able to visualize the lines and angles of your course.
You should look for and remember any major landmarks that you could follow to retrace your course back to the boat. Particularly remember those at your starting point or close to it.
Bottom line for beginning navigational skills, at any point along the way, you should be able to stop and ask yourself, "what direction to the boat" and turn and point generally in the right direction - close enough that if you swam that direct course, you would come close enough to spot the landmarks where you started. You can test your own ability to keep oriented this way even while you are following a DM around on a reef. Keep track of the point(s) where you start losing your confidence in your ability to fix your location in relation to the starting point, and think about it later. It all starts coming together pretty quickly when you make a point of thinking about it as you are diving.