As with any food, purchase beef only from a reputable, licensed farmer, and inspect it prior to purchase. If the farmer butchers the cattle on site, consider the cleanliness of the slaughterhouse.
When considering quality, research the breed of cattle being raised on the farm. Not all breeds provide the same quality steaks or roasts due to genetic differences in marbling, size of muscles and flavor. For example, Angus cattle is considered to have superior flavor and marbling and would therefore be preferable to most other breeds. If you are unfamiliar with the breed, research it before buying.
The feed used on the farm also affects the flavor of the beef. "Grass fed" is a common marketing tool and sometimes a dubious distinction, but the more natural and neutral the diet, the less non-beef flavor it imparts on the final product.
Cleanliness of the facility should also be a primary concern when purchasing directly from a farmer. If the seller is handling beef or carcasses after slaughter, make sure he is observing safe food handling guidelines. Major areas of concern should be the sanitation procedures in the slaughter house, refrigeration practices after the cow has been slaughtered, and what the facility is used for other than processing beef.