I'm way less worried about homing attack than about fifty other things. If he's using homing attack to fight you, he's either toying with you or just a bad player.
I play against X, so I'm a little biased about this matchup.
FD is a terrible stage for Link against Sonic, ban it. Just btw.
Arrow cancelling is going to be used a lot in this matchup just to put a quick wrench in Sonic's assault.
Sonic has total space and zone control in this matchup. He goes under zair, arrows and boomerang can only occasionally mess up his ground mindgames, and projectiles are a joke. Nair tends not to have enough range compared to Sonic's aerials when you're knocked into the air and are defending against him. Honestly I think bair replaces zair and nair in this matchup, you're going to have way better chances of fighting him if you use the SH bair reverse AC technique to play defensively. Even if Sonic manages to knock you up, bair has better range than every single one of Sonic's aerials except his own bair.
Sonic's uair outranges our dair I believe. It's a pain of a move, and used in conjunction with UpB it makes a frightening juggle finisher. FF airdodge is probably Link's only good response to getting knocked up high, which just shows Sonic's juggling dominance in this MU.
Boomerang's wind effect could be useful in this matchup. Throw it behind you while sonic is charging up his spin moves, then start playing the SH bair style, and then just dodge the returning boomerang. It could very likely save you from his juggling, and unfortunately, doing something as desperate as that may just be better than any other response Link has to being juggled. At least Sonic's air maneuverability is terrible. A little push from the wind effectively negates anything Sonic can do until he gets back to the ground.
Link's smashes, when unleashed, will kick Sonic's butt though. Sonic is fairly light, so even at low percentages desperately throwing around smashes can knock him far enough away to reset spacing. Jab is fast, but I think it clashes or is outprioritized by Sonic's spin moves on the ground, so I wouldn't expect to use this much except as a "get off me" move. Utilt and usmash are great for dealing with an airborne Sonic, although if he expects it and airdodges then you'll get punished with a grab, fsmash, or something else. Mix it up with grabs and smashes.
If Sonic is forced to UpB off the edge, then Link has several options to deal with him. He can do the grab technique, although it's quite difficult for Link to place it correctly to get the grab. Uair will be scary for Sonic; it outlasts any airdodge and has underrated killing strength. It will always be fresh as well.
Homing attack may be used to mix things up, but bair, fair, and dair all outspace it while in the air and utilt will easily outrange it. Don't expect to see this much.
BF is a bad stage due to the small horizontal range onstage and low ceiling. You WILL get uair KOed at least once a match on this stage. FD is bad because of way too much flat, horizontal space. Mix up the stages, such as using YI with it's uneven terrain. If you grab Sonic, but he lands on the ghost, you can dair KO him. Brinstar has a fairly high ceiling with uneven ground that even stops Sonic in some places, forcing him to take to the air. The sides are close, giving easy horizontal KOs to Link. Halberd favors Sonic, as Sonic can camp the middle, and if you get on the sides you have no options to deal with him. The ceiling is *just* high enough for him to easily uair KO you as you try to momentum cancel.
60:40 Sonic.