How do you know when surgery is needed for a widening AC joint, I have had the pain for about 4/5 months now. Thanks?

Fix pain/instability. Mere widening of your ac (acromioclavicular) joint is not an indication for surgery. Pain from arthritis or osteolysis can cause joint space widening or narrowing and lead to surgery. Trauma or injury can generate instability and widening too (usually with prominence of the end of the clavicle) that can lead to ac joint reconstruction.
AC injury? Need more information. Was there an injury? Any treatment yet, such as rest and nsaids? Any injections not ac joint to ensure that is where pain is coming from?
Function and pain. If the separation is interfering with your quality of life or your money making ability and/or if the pain is getting to you, have it checked by an orthopedist. Weigh the success rate against the benefit.