Your proficiency bonus is applied if you have proficiency with the weapon. This is generally determined by your class. Other factors may grant you proficiency with other weapons (e.g. High Elves have proficiency with longsword, shortsword, shortbow and longbow in addition to whatever weapons their class grants).
Strength vs Dexterity
In general, melee weapons use Strength and ranged weapons use Dexterity. Of course, there are exceptions (see Weapon Properties on PH p. 146-7.).
If the melee weapon is marked finesse, then you may use Dexterity or Strength (e.g. Rapier).
If the ranged weapon is marked thrown and may also be employed as a melee weapon, then you employ Strength rather than Dexterity (e.g. Spear).
If a ranged weapon is marked thrown, may be employed as a melee weapon, and is marked finesse, then you may employ Strength or Dexterity (e.g. Dagger).