Getting your bird to accept you petting it is more about being in tune with your bird and learning to work with its personality than it is about training.
Birds' comfort level with people can vary greatly, and some just like their personal space. If you have a bird that does not like to be touched, you will need to learn how to approach it in order to make it comfortable with contact.
If you have a cuddly bird that likes human contact, it probably won't take much effort at all to get your bird lowering its head to get you to scratch it. Some birds, such as parrots, budgies and parakeets are more likely to allow touching than others. But even within bird species, there are different personalities.
Bird Body Language
When training your bird to accept petting, the first step is to read the cues your bird is giving you. Remember that reaching for your bird's head to pet it may be perceived as a threat, especially if you try to reach the back of the head.
Does your bird assume a stiff posture and stare at you when you approach it? Does it run away, try to push you away, or even try to bite you? These are clear signs that your bird is not comfortable with what is happening.
If you ignore the body language of a stressed bird, prepare for a potential bite from them. On the other hand, a bird that likes being pet is relaxed and will often turn its head a bit to the side, or even bow its head down, for scratches and petting.
Some will bow their heads down and even close their eyes, a sign of a happy bird that fully trusts that petting is not a threat.
Teaching Your Bird to be Comfortable with Being Pet
You can do a little bit of training to get your bird more comfortable with the idea of being pet. As with other forms of training, practice in short frequent sessions and don't press on if your bird is cranky or grows tired. You can always try again another day.
Prepare Your Bird
Choose a quiet time when your bird is relaxed, after eating or just before its usual bedtime. Use a very gentle touch when petting your bird. Keep your hand in full view of your bird, and speak to it before petting it. Don't try to force it; if the bird resists, take a break.
Start With the Beak
Try lightly touching and petting your bird's beak at first. Be careful not to poke its eyes, and be prepared for it to try to nip you (more of a threat from a larger bird, obviously).
If your bird lets you touch its beak, try gradually moving your fingers to the skin on its face just behind the beak. Work your way around the side of your bird's head if it is comfortable with you petting its beak and face.
Pet in One Direction
Work with the natural orientation of the feathers. Petting the feathers against the grain can be irritating for the bird. Pet in the direction the feathers naturally lay down, or gently scratch side to side between the feathers.
Eventually, as your bird relaxes, you can work your way around to the back of its head and neck.
Problems Petting Your Bird
While a good cuddle might be nice for you and your bird, it is a good idea to avoid excessive petting and to avoid petting the back and body of your bird. A mature bird may find petting in these areas stimulating which may result in a sexually frustrated bird and, in turn, may lead to behavior issues.
Make sure petting doesn't become the only way you interact with your bird. Ensure you are socializing with your bird in other ways (i.e. tricks, games, exploring, toys, talking, just being together).
Ultimately, if your bird does not respond to your attempts to pet it, you may just have to accept that it's not a cuddly bird and be content with admiring it and caring for it from afar (or, from a short distance). Persisting in petting a bird that just doesn't like contact is going to erode your bird's trust in other areas.