you should override the onBlockPlacedBy method
in this method you can get the block ID and the metadata so it would look like this:
@Override
public void onBlockPlacedBy(World world, int X, int Y, int Z, EntityLivingBase entityLivingBase, ItemStack itemStack)
{
int metadata = world.getBlockMetadata(X, Y, Z);
int playerDirection = MathHelper.floor_double((double)((entityLivingBase.rotationYaw * 4F) / 360F) + 0.5D) & 3;
if(metadata == 0)
{
switch(playerDirection)
{
// then you put here what metadata will be placed based on where you're pointing at like this
case 0: metadata = 2; break;
}
}
world.setBlock(X, Y, Z, blockID, metadata, 2);
}