The answer to this question assumes that your sofa does not have built-in legs that cannot be removed.
When buying replacement sofa legs there are two things to watch out for:
The leg height. Raising or lowering the leg height by 1″ or more can make your sofa much less comfortable than what you are used to.
The exception is that if you have leg or back problems that make it difficult to get up from your sofa you may want a higher leg.
Most sofa legs that screw on use a 5/16″ shank. That is standard, but there are some exceptions.
A previous answer by Ken Adney states that you can just google “sofa legs” to find suppliers.
This is correct, however you will find both retail and wholesale pricing available on various websites. Some of these wholesalers will sell their legs in small quantities at reduced pricing.
For example Amazon charges $28 each for a leg similar to what can be found on BingLtd.com for $4.40 ea.