Use OnHit Cast Spell: Unique Power (OnHit) as the weapon's item property. Then you'll need a unique item script whose name matches the tag of the item you created. Below is an example script that casts Bull's Strength on the weapon wielder when the target is hit.
#include "x2_inc_switches"
void main()
{
int nEvent =GetUserDefinedItemEventNumber();
object oPC, oItem;
if (nEvent ==X2_ITEM_EVENT_ONHITCAST)
{
//do bull's strength bonus on the wielder for one hour
oItem = GetSpellCastItem();
oPC = GetItemPossessor(oItem);
effect eStr = EffectAbilityIncrease(ABILITY_STRENGTH, 4);
effect eVis = EffectVisualEffect(VFX_IMP_IMPROVE_ABILITY_SCORE);
effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE);
effect eLink = EffectLinkEffects(eStr, eDur);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oPC);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oPC, HoursToSeconds(1));
}
}