Many boys discover masturbation by accident, when they are rubbing their penis and feel something so good that they have just continue until they have an orgasm. But there are many methods for making it more pleasurable.
There will be times when you have a strong desire to masturbate but it's not convenient to do so. In this case you can ejaculate as quickly as possible, perhaps in the bathroom. This is fine - but you should know that masturbation, just like sex between two people, is much more pleasurable when you can relax and take your time.
Some guys masturbate lying face down and rubbing their penis against the bed. One very common technique is to lie on your back and rub or massage your penis with your hand. In this position, when you ejaculate the semen will end up on your chest or stomach, which is easier to clean up. (You will probably want to get up and take off your night-clothes or T shirt, so that the semen won't wet them, and keep a tissue handy to clean yourself afterwards.)
Every successful masturbation session starts with an erection, which happens when your penis fills with blood until it is hard and you can play with it with your hand. Getting an erection is usually easy, either through thinking erotic thoughts or by manual stimulation. If you are young, or have not ejaculated for some time, you probably don't have to do much to get an erection!
Once your penis has reached its maximum length and hardness, hold it and rub it along the entire length, keeping a constant rhythm. This simulates the feeling of moving your penis to and fro inside a woman's vagina, which is what happens during sexual intercourse.
There are many ways of stimulating the penis which you can try. These are just starting points: it's important to practice your own variations, so that you find the techniques which give you most pleasure.