As a general guide: As further you walk along the beach to the last resort, the better and quieter the accommodation.
You can usually find accommodation at the pier when you arrive, many of resorts offers taxi service from pier for free. However, during the full moon period it is worth booking ahead unless you want to sleep on the beach or spend the night in one of the more expensive lodgings. If you are thinking of booking accommodation on-line before you arrive, make sure you book direct with the resort or a trustworthy booking site as there are numerous fake sites for several well-known Ko Pha Ngan resorts appearing on the Internet.
There is more to Ko Pha Ngan than the Full Moon Party and Haad Rin, so don't be afraid to venture out to other beaches. You can still get to the party from just about everywhere.
The decent rooms tend to run out a few days before the Full Moon Party, and throughout the peak season (Dec-Feb). If you have a short vacation or like to have a soft landing, you might want to book a room in advance. This can be quite hard on the less accessible beaches, such as Haad Tien or Haad Yuan.
If you decide to test your luck, try to arrive as early in the day as possible (09:00 seems to be a good time) to have the most time and options for accommodations.
If you come in relatively low-season in Jul and Aug, it is a good idea to book a room in advance just for the first night and rent a motorbike to look around. Beaches differ a lot (some of them are good for diving/snorkelling, some are good for swimming), so do villages (some are really quiet, some are packed with bars). Motorbike trip by the seaside to Chalok Lam and all the places on the way, and to Haad Rin on the other end of the island. Should not be a problem even for less experienced riders and will help you to choose the perfect place which suits your preferences. More remote places are harder to get by motorbike, so if you are thinking about staying in Thong Nai Pan or Bottle Beach, you have to rely on reviews.
For a cheap bungalow, literally moments from white beaches (but no surf whatsoever), turn left from Thong Sala and you will pass strings of quiet bays, each with one or more resorts, featuring a bar, a restaurant, rooms and bungalows, and a few dozen laid back tourists for company. Try Haad Yao, Haad Son, Haad Salad or any of the others along the same strip.
For the north of the island, Chalok Lam, Ko Ma/Haad Mae Haad, Haad Khom & Bottle Beach are popular.
For long-term stay, you can rent whole house (1 bedroom, small kitchen, bath, Wi-Fi, electricity/water included) for 5-6,000 baht/month, not on the beach. Bigger houses with 2 bedrooms from 10-12,000 baht/month. For a 2 week booking, don't expect half of the monthly price. Two weeks in a 2 bedroom house costs a minimum of 7-9,000 baht, 1 bedroom 3-4,000 baht.